Talk:Robocode/My First Robot

From RoboWiki
Jump to: navigation, search


I am an experienced 13 year old Java programmer, and I decided to try this, (it looks VERY cool) but when I try to compile the simple default program it gives many errors. I figured out pretty quickly; it can't find the robocode package. I need to like set the classpath, but I can't directly do this. >=( Robocode SHOULD do this on its own...

Ok, I figured it out on my own... It's different on a mac. Awesomeness 01:01, 13 March 2009 (UTC)

Robocode can't simply do everything for you, becasuse it is a Java setting issue, if you are using Eclipse you can set it trough the Build Path Settings, on the Libraries tab, select Add External Jars, search for your Robocode instalation directory (default in Windows is C:\robocode) under that directory there should be a libs directory, there are four jars, you might not need all of them, but I recommend you add all of them for now.

If you are compiling from the console you should do something like

javac -cp C:\robocode\libs\cachecleaner.jar;C:\robocode\libs\codesize.jar;C:\robocode\libs\robocode.jar;C:\robocode\libs\roborumble.jar ...

To set the classpath, but I really recommend using an advanced IDE like Eclipse (or whatever you prefer, ie. NetBeans). Hope it helps, and welcome to Robocode. --zyx 08:55, 11 March 2009 (UTC)

Actually Zyx, you don't need the cachecleaner, codesize or roborumble jars ofr compiling bots. --Rednaxela 12:44, 11 March 2009 (UTC)

Maybe this is easier?

javac -cp C:\robocode\libs\*; ...

it load every library in /libs automatically. (ripped from Robocode 1.7 startup files) » Nat | Talk » 13:14, 11 March 2009 (UTC)

Yes Rednaxela, you are right that for compilation there is no point to include any jar that is not robocode.jar. I didn't know that the * wildcard worked but is good to know Nat. But all my disinformation comes from Eclipse, I added the 4 jars there and he knows what to use :-). --zyx 19:44, 11 March 2009 (UTC)

I don't think the * will work for .jar files. It works for .class files only. Well, that was my experience several years ago, when I last used Windows. --Skilgannon 19:49, 11 March 2009 (UTC)

  • I had to test it, it works as Nat posted it, but if it is missing that ; after the * it tries to use the jar files as input files and of course fails. But bottom line is that it does work. --zyx 00:29, 12 March 2009 (UTC)
  • It should work because robocode 1.7 later than use this method. I myself just add robocode.jar to eclipse :-) » Nat | Talk » 00:51, 12 March 2009 (UTC)


I can create my robot without a problem but when I go to compile it, it doesn't do anything and won't let me save it. Thoughts? I can set up battles (can't save them either...) and don't have the javac file which I think may be what's causing this. If it is, where is a good place to download it? I'm using Windows XP and I don't know if it's a 32-bit or 64-bit.--Giants27 21:52, 24 May 2010 (UTC)

I think you want to get the JDK for Windows here: [1]. If you don't know, I'd go with 32-bit. I thought Robocode would setup the "jikes" compiler if you didn't have javac installed, but I'm not sure. Once you have the JDK installed, (I'd probably restart Robocode, then) go to Robot Editor, Compiler > Options > Reset Compiler and it should find javac. Btw, are you getting an error when you try to compile, or what happens? You might also find some good info at Robocode/System Requirements or in Category:Tutorials. Good luck! --Voidious 21:59, 24 May 2010 (UTC)

When I go to compile, nothing happens and it just sits on the robot editing screen. It did install "jikes" but for whatever reason it still does nothing when I go to compile. I'll go try to install that.--Giants27 22:07, 24 May 2010 (UTC)

I installed JDK from here but, the robot editor still doesn't detect javac and I still can't save anything.--Giants27 22:20, 24 May 2010 (UTC)

Not that this has any relevancy to the discussion but why don't we include Javac instead of Jikes with robocode. I believe javac is open-sourced here: [2]. --Exauge

Interesting that Fnl just tweeted about a new default Java compiler today: [3]. --Voidious 00:16, 26 May 2010 (UTC)

Anything?--Giants27 22:17, 25 May 2010 (UTC)

I'm still a bit baffled about the actual problem, but you don't need to use the Robocode Editor to compile a robot. Many of us use Eclipse. You can start reading about that here if you want to try: Robocode/Eclipse. --Voidious 00:16, 26 May 2010 (UTC)


Thread titleRepliesLast modified
Literally so unhelpful118:27, 30 May 2015
Weird problem320:19, 27 October 2013
please help008:02, 14 March 2013
Compiled but can't see...817:12, 14 October 2012

Literally so unhelpful

I am an AP Computer Science student trying to create a robocode robot, because our teacher literally told us "this is your final teach yourself the API from online resources and then you're turning it in instead of a real test". I already know how a while loop works. The exact reason I cam was for learning how to get the results of a scan, but after skimming all the basic "how to use a while loop" stuff I see

>The game calls your onScannedRobot method whenever—during one of the actions—you see another robot. It sends along an event that can tell us lots of information about the robot—its name, how much life it has, where it is, where it's heading, how fast it's going, etc. However, since this is a simple robot, we're not going to look at any of that stuff. Let's just fire!

I came looking for "It sends along an event that can tell us lots of information about the robot—its name, how much life it has, where it is, where it's heading, how fast it's going, etc." and how to use that. I am not a java noob, I am a robocode noob. The sourceforge API thing isn't helping, it assumes A LOT of prior knowledge on the game that I don't have.

Can anyone make a tutorial for people new to robocode, but not java? Is there one I just can't seem to find? I'm so confused and I have no idea how to even get started.

Thank you!

SakuraKaminari (talk)13:29, 29 May 2015

On the front page of the wiki you will find the link to Tutorials. You'll probably be most interested in Robocode/Game Physics and Robocode/FAQ.

Skilgannon (talk)18:27, 30 May 2015

Weird problem

Several years ago, I was very active in robocode and may have screwed around with it a bit (not really sure anymore). Now, I've come back to find robocode behaving very weirdly. When I use the default robocode editor to make a new robot, save and compile it, the compiled .class file appears in the .robocode/robots directory in the appropriate package. However, when I make a new battle, neither the robot or its package show up (even after refreshing). When I removed some of the older bots already in the directory and refreshed the robot list, however, they were also removed from the robot list (Wierd, huh? It's almost like it ignores any new packages). I tried deleting the .robocode directory and retrying everything, but the result didn't change.

AncientPyro (talk)22:02, 20 October 2013

That does sound strange. What version of Robocode are you using? Fnl has made quite a lot of improvements to the app in recent years, so I'd probably just install a fresh copy and then copy over my robots directory.

And welcome back. :-)

Voidious (talk)23:46, 20 October 2013

Hey Voidious,

Sorry for the late reply. I'm still not sure what the problem was, but I'm pretty sure it had to do with the fact that I downloaded the ubuntu-tailored version from the Synaptic Package Manager. It was an older version as well. I tried reinstalling that without success. However, when I downloaded a fresh version from online it worked just fine (except for abysmal performance when using graphical debugging (it is seriously awful)).

p.s: When battling my new bot KBot against Dookious, I get 31% out of 10 battles :D. Remarkable since I just mashed together random movement + wall smoothing with an admittedly pretty powerful k-means clustering gun.

AncientPyro (talk)19:57, 27 October 2013

There are some graphics settings in preferences that might help. I don't think it defaults to "Fast".

I'm not sure if Robocode is equipped to run from an installed location like that. It seems entirely possible to me the package is just broken. (Note it's not necessarily the author, who'd probably know how to do it right, that packaged it.)

Keep up the good work vs Dookious. :-) He's still a pretty tough cookie.

Voidious (talk)20:19, 27 October 2013

please help

I'm new to coding and would like someone to refer me to a link that can help teach me how to "write" my first code for my first robot. All the websites and blogs I've seen just show peoples codes but I don't understand what they did to change anything.


Jlflour08:02, 14 March 2013

Compiled but can't see...

I set up a robot project on my NetBeans. I loaded the robocode libraries, etc. All this seemed to go successfully. I can even compile my robot class with success. I also pointed robocode to the directory my robot class is in.

But my robot doesn't show up in the robot list for fights!

Any ideas? Thanks.

Therealdrag004:35, 1 October 2012

Hi! How you "pointed robocode to the directory my robot class is in"? What this directory contents? Do you added ${}.properties file? Which package are you use?

Jdev11:34, 1 October 2012

Thanks for the reply!

I added the directory, "C:\MyRobots\build\classes\zjk", to development options. In that directory is only the class file, "drag0.class"

Okay, since you mentioned properties file, I looked around (I don't see any ${}.properties file). I tried adding the other directories above the one mentioned above and it still doesn't work. how is a .properties file generated and what is its purpose?

Therealdrag020:37, 1 October 2012

The .properties file is added to the JAR when you package your bot, but it shouldn't be needed in order to see a development version of your bot. I'm not sure, but I think you'll need to add the top level directory in Robocode - e.g., if your bot is zjk.MyRobot, under ...\build\classes\zjk\, you'd need to point Robocode to ...\build\classes.

I have my things setup the other way, with Eclipse compiling the .class files into robocode/robots/, but that's kind of a stupid setup that I've just never bothered to change.

Voidious21:06, 1 October 2012

Not that stupid. Many times I saw a development version working, only to generate a non-working JAR. Wrong .properties file, security violations, wrong file names...

And the opposite problem (non-working development versions) arises when you use the engine API directly instead of the GUI . i.e. genetic tuning with full battles.

I also develop and test using JARs instead of raw .class files.

MN21:30, 1 October 2012

There was one time when codesize calculated the wrong size for a nanobot, adding the size of 2 development bots together.

I ended trying to shrink the code a lot only to discover it did already fit in the nanobot category before with lots of room for more code.

MN21:39, 1 October 2012

Okay, so I took the .class file and folder and threw it in the native Robocode folder and it works fine. So I know that's okay.

But still when I have it in my dev folder it doesn't show. In Robocode I have added: C:\MyRobots\build\classes\zjk C:\MyRobots\build\classes\ C:\MyRobots\build\ C:\MyRobots\

...and none of them work! :/

Therealdrag023:23, 1 October 2012

Did you add them all at the same time? I had problems with multiple classpath folders.

And the correct path should be C:\MyRobots\build\classes

MN12:58, 2 October 2012

Thanks I got it to work.

Therealdrag017:12, 14 October 2012
Personal tools