With this example, sample.RamFire will battle against sample.Corners. If you create a robot like my.KillerRobot, then you just include this in the argument given to the getLocalRepository(..) method.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there any way to include robots that haven't been compiled yet? I have Robot objects in my Java program that I'm trying to control through external software. I can come up with a work-around if I'm unable to place Java Robot objects themselves into a battle directly without compiling them, but I was wondering if there was a cleaner way to do so.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, Robocode requires .class files for the robot or team that is going to participate in the battle. This is necessary, as the security manager in Robocode needs to check if the robot 'misbehaves' etc. prior to being run or during the battle looking and the robot actions.
You say you have "Robot objects". What are these? Are these memory instances of the robot based on some class or? I just need to know the form in order to determine if there is a smart way to include those robot objects. :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yup, these are memory instances of a class I have that extends Robot. I think I can find a work-around that involves writing/compiling a .java file programatically, but if you know of a better way, I'd be very open to that.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've written some functions that write all of my robot's functionality to a java file, so if there's no way to put robots in memory into battles directly, is there a way to compile robots via command line? Do you just directly compile the .java file normally? Or is more required?
Last edit: fasterthanlight 2013-06-04
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is no way to put robots in memory directly into battle. But if you somehow persist the robot object class(es) into class files (with the correct class format and put in the correct java package and into the robots directory), then the RobocodeEngine will be able to read the robot. Doing so is definitely out of scope for Robocode, but that is exactly why we have the RobocodeEngine, so customization can be made on top of the engine.
I guess libraries like e.g. Apache BCEL or Javassist might be useful for persisting an robot object class into a class file.
If you have a java file, you just compile it using the regular javac compiler or e.g. ecj (Eclipse Compiler for Java). Actually, you can use the compiler options used by Robocode. See the Compiler Options from the Robot Editor (Robot -> Editor, Compiler -> Options -> Preferences). You just concatenate all the values from the options dialog into e.g...
Hello!
I'm having the same trouble, and so it seems the answer is no, there is no clean way to do so. But anyhow, in my case I can also design my Robot to read it's settings from a txt file (the weights of a neural network) This way I can precompile the Robot manually and overwrite this text file every time with new weights and then start a new battle.
But it seems I cannot overwrite robots/.data/<package>/Robot.data/settings.txt (yes, my robot is named Robot.). By turning off security this can be worked around for a manually started match ( -DNOSECURITY=true in robocode.bat), but I cannot find how to turn off the security for the RobocodeEngine object.
How do I overwrite a this file anyway? OR How do I turn off security for a controlled robocode engine?
If this works maybe this is interesting for fasterthanlight as well!</package>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I found a hack: remove robots/<package>/Robot.data/settings.txt and then it won't be copied to robots/.data/<package>/Robot.data/ and there protected so you cannot overwrite it. Afterwards you create it anyway and you can still overwrite it.</package></package>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I am using some external software to create/control robots, and I can't
find the functionality I'm looking for in the control package--
I have two Robot objects, and I want to put them into battle with each
other and see who wins.
What's the easiest way to do this?
The way to do it is like shown in the example code with the BattleRunner.
You select the robots that must participate in the battle using:
With this example, sample.RamFire will battle against sample.Corners. If you create a robot like my.KillerRobot, then you just include this in the argument given to the getLocalRepository(..) method.
Thank you for the reply!
Is there any way to include robots that haven't been compiled yet? I have Robot objects in my Java program that I'm trying to control through external software. I can come up with a work-around if I'm unable to place Java Robot objects themselves into a battle directly without compiling them, but I was wondering if there was a cleaner way to do so.
Well, Robocode requires .class files for the robot or team that is going to participate in the battle. This is necessary, as the security manager in Robocode needs to check if the robot 'misbehaves' etc. prior to being run or during the battle looking and the robot actions.
You say you have "Robot objects". What are these? Are these memory instances of the robot based on some class or? I just need to know the form in order to determine if there is a smart way to include those robot objects. :-)
Yup, these are memory instances of a class I have that extends Robot. I think I can find a work-around that involves writing/compiling a .java file programatically, but if you know of a better way, I'd be very open to that.
I've written some functions that write all of my robot's functionality to a java file, so if there's no way to put robots in memory into battles directly, is there a way to compile robots via command line? Do you just directly compile the .java file normally? Or is more required?
Last edit: fasterthanlight 2013-06-04
There is no way to put robots in memory directly into battle. But if you somehow persist the robot object class(es) into class files (with the correct class format and put in the correct java package and into the robots directory), then the RobocodeEngine will be able to read the robot. Doing so is definitely out of scope for Robocode, but that is exactly why we have the RobocodeEngine, so customization can be made on top of the engine.
I guess libraries like e.g. Apache BCEL or Javassist might be useful for persisting an robot object class into a class file.
If you have a java file, you just compile it using the regular javac compiler or e.g. ecj (Eclipse Compiler for Java). Actually, you can use the compiler options used by Robocode. See the Compiler Options from the Robot Editor (Robot -> Editor, Compiler -> Options -> Preferences). You just concatenate all the values from the options dialog into e.g...
Of course this depends on the specific OS etc.
After the above command-line you add the classes you need to compile, of course. :-)
This is actually the way Robocode compiles the robot Java files.
You can call this command line tool using the ProcessBuilder in Java. :-)
Hello!
I'm having the same trouble, and so it seems the answer is no, there is no clean way to do so. But anyhow, in my case I can also design my Robot to read it's settings from a txt file (the weights of a neural network) This way I can precompile the Robot manually and overwrite this text file every time with new weights and then start a new battle.
But it seems I cannot overwrite robots/.data/<package>/Robot.data/settings.txt (yes, my robot is named Robot.). By turning off security this can be worked around for a manually started match ( -DNOSECURITY=true in robocode.bat), but I cannot find how to turn off the security for the RobocodeEngine object.
How do I overwrite a this file anyway? OR How do I turn off security for a controlled robocode engine?
If this works maybe this is interesting for fasterthanlight as well!</package>
I found a hack: remove robots/<package>/Robot.data/settings.txt and then it won't be copied to robots/.data/<package>/Robot.data/ and there protected so you cannot overwrite it. Afterwards you create it anyway and you can still overwrite it.</package></package>