Re: How to Use BattleRunner

Jonathan Addison <[email protected]> Fri, 24 Mar 2017 01:39:48 -0700 (PDT)
Newsgroups gmane.comp.java.robocode
Message-ID <[email protected]>
Many Thanks Patrick, but I'm still struggling. So I tried putting on the 
command line java -cp path/to/robocode.jar BattleRunner and I get Error: 
Could not find or load main class BattleRunner. But BattleRunner is 
definitely there, as I can do java BattleRunner and get that wonderful 
printout seen earlier. I tried moving BattleRunner to C:\robocode but then 
it won't compile with javac -cp robocode.jar BattleRunner.java saying 
packing robocode.libs.control doesn't exist (even though it happily 
compiles in C:\robocode\libs).

I looked at your RoboRunner, I run Windows, is it going to be suitable?




On Thursday, March 23, 2017 at 12:41:20 AM UTC, Patrick Cupka wrote:
>
> Hey! A few thoughts / suggestions:
>
> - Passing "-jar robocode.jar" basically means robocode.jar is the program 
> you want to execute. In this case, you want to execute BattleRunner and 
> link in robocode.jar (your code references Robocode's). So you want 
> robocode.jar on your "classpath", with a param like: "-cp 
> path/to/robocode.jar". And probably execute it from the dir with 
> BattleRunner in it.
>
> - One issue you'll face is that you can't simply run multiple Robocode 
> engines in different threads. You need a separate process and install 
> directory for each Robocode that's running. I wrote a battle running tool 
> called RoboRunner which handles that pretty well: 
> http://robowiki.net/?RoboRunner ..  If you're running battles overnight, 
> you'll definitely want multi-threading. It's possible you have some need to 
> interface with the Robocode Control API directly, but I'd consider instead 
> trying to interface with RoboRunner to run your battles. But if nothing 
> else, it's good reference code for how to use the Control API.
>
> - A tip from someone else who's played with GA and Robocode: one hurdle 
> with genetic algorithms in Robocode is that each piece of code you want to 
> test has to be packaged into a .jar for Robocode to run battles with it. 
> Alternatively, you could evolve the contents of a data file that your bot 
> reads in and have that dictate the behavior. This will be an issue whether 
> you use RoboRunner or the Control API. It's one reason all my Robocode GA 
> experiments ended up being run fully outside of Robocode, against data sets 
> collected with Robocode. And I actually wrote a game called BerryBots with 
> a different style of automation API and made sure it's a bit friendlier to 
> things like GA.
>
> Hope that helps! Let us know how it goes. Good luck,
>
>
> On Wed, Mar 22, 2017 at 10:22 AM, Jonathan Addison <
> [email protected] <javascript:>> wrote:
>
>> Hello, I'm trying to write a genetic program for robocode. I want the 
>> battles to be automated, so that I can run the program at night. However, I 
>> can't seem to work out how to do it. I've Ctrl-C the source code from 
>> http://robocode.sourceforge.net/docs/robocode/robocode/control/package-summary.html (I 
>> believe this is for robocode 1.9.2.0) and I'm definitely using 1.9.2.4 . It 
>> compiles, but I get a runtime error.
>>
>> I enter java BattleRunner on the command line (I use Windows 10)
>> I've tried java -jar robocode.jar BattleRunner and that doesn't change 
>> anything.
>> and get this Error: A JNI error has occurred, please check your 
>> installation and try again
>> Exception in thread "main" java.lang.NoClassDefFoundError: 
>> robocode/control/events/IBattleListener
>> at java.lang.Class.getDeclaredMethods0(Native Method)
>> at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
>> at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
>> at java.lang.Class.getMethod0(Class.java:3018)
>> at java.lang.Class.getMethod(Class.java:1784)
>> at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
>> at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
>> Caused by: java.lang.ClassNotFoundException: 
>> robocode.control.events.IBattleListener
>> at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>> ... 7 more
>>
>> My robocode is installed @ C:\robocode. BattleRunner is stored @ 
>> C:\robocode\libs.
>>
>> I can robocode from the command line, but once that's open I can't use 
>> the command prompt.
>>
>> I'm very sorry, if this has already been answered, many thanks for your 
>> time.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "robocode" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Patrick Cupka, [email protected] <javascript:>
> --
>

-- 
You received this message because you are subscribed to the Google Groups "robocode" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.