Can't find my robot to test it out in battle

429 views
Skip to first unread message

ian.r....@gmail.com

unread,
Oct 18, 2018, 5:06:33 PM10/18/18
to robocode
So I made some tweaks to the template to see how the robot would behave. Unfortunately I can't find it to select for a battle. It's in the robot map in the map irtatters (that's what I called the package). Now if I want to start a new battle I see all the packages like sample, team, ect. but not irtatters. I tried control r and clean robot cache. Can someone help me?

fnl

unread,
Oct 18, 2018, 5:22:52 PM10/18/18
to robocode
Hi Ian,

I am not sure I understand, what you try to do. Regarding templates, Robocode has 3 predefined templates:
  • newjavafile.tpt
  • newjuniorrobot.tpt
  • newrobot.tpt
These are used for the Source Editor, when creating a new Java file, JuniorRobot, or Robot. Of course, you are free to modify those templates, if you want to.
A template will just flesh out a Robot class. Hence, when you compile your robot class, it should show up when selecting robots for a new battle.

You could send me your template to fnl (at) users.sourceforge.net, so I can check if something is not right.

Cheers,
- Flemming

Ian Tatters

unread,
Oct 19, 2018, 6:24:29 PM10/19/18
to robo...@googlegroups.com
Hey Flemming,

I selected the robot one in the source editor. I did compile it, but it still doesn't show up when I want to select robots for a battle.

This is my code. It's fairly simple, I just wanted to see if the robot worked.

package irtatters;
import robocode.*;
//import java.awt.Color;


/**
 * Hey - a robot by (your name here)
 */
public class Hey extends Robot
{
/**
* run: Hey's default behavior
*/
}
public void run() {
// Initialization of the robot should be put here

// After trying out your robot, try uncommenting the import at the top,
// and the next line:

// setColors(Color.red,Color.blue,Color.green); // body,gun,radar

// Robot main loop
while(true) {
// Replace the next 4 lines with any behavior you would like
ahead(100);
turnRight(45);
}
}

/**
* onScannedRobot: What to do when you see another robot
*/
public void onScannedRobot(ScannedRobotEvent e) {
// Replace the next line with any behavior you would like
if (e.getEnergy() > 25) {
fire(3);
} else if (e.getEnergy() > 10) {
fire(1);
}
}

/**
* onHitWall: What to do when you hit a wall
*/
public void onHitWall(HitWallEvent e) {
// Replace the next line with any behavior you would like
back(30);
}
}


--
You received this message because you are subscribed to a topic in the Google Groups "robocode" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/robocode/PPPqVcb6Mvs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to robocode+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

fnl

unread,
Oct 19, 2018, 6:30:10 PM10/19/18
to robocode
Hi Ian,

I tried to compile your robot in Robocode, and soon found the issue. You have a misplaced curly bracket between the comment and declaration of your run method. Hence, I cannot compile your robot.
So I guess the issue is due to a tiny issue. :-)

/**
* run: Hey's default behavior
*/
}
public void run() {

Compiling...
[parsing started RegularFileObject[C:\robocode\robots\irtatters\Hey.java]]
C:\robocode\robots\irtatters\Hey.java:16: error: class, interface, or enum expected
public void run() {
       ^
C:\robocode\robots\irtatters\Hey.java:28: error: class, interface, or enum expected
turnRight(45);
^
C:\robocode\robots\irtatters\Hey.java:29: error: class, interface, or enum expected
}
^
C:\robocode\robots\irtatters\Hey.java:35: error: class, interface, or enum expected
public void onScannedRobot(ScannedRobotEvent e) {
       ^
C:\robocode\robots\irtatters\Hey.java:39: error: class, interface, or enum expected
} else if (e.getEnergy() > 10) {
^
C:\robocode\robots\irtatters\Hey.java:41: error: class, interface, or enum expected
}
^
C:\robocode\robots\irtatters\Hey.java:48: error: class, interface, or enum expected
public void onHitWall(HitWallEvent e) {
       ^
C:\robocode\robots\irtatters\Hey.java:51: error: class, interface, or enum expected
}
^
[parsing completed 51ms]
[total 87ms]
8 errors
Compile Failed (1)


torsdag den 18. oktober 2018 kl. 23.06.33 UTC+2 skrev ian.r.tatters:

Ian Tatters

unread,
Oct 20, 2018, 7:00:14 PM10/20/18
to robo...@googlegroups.com
Hey, I corrected the error and compiled it. I got this message.

Compiling...
Eclipse Compiler for Java(TM) v20180305-0940, 3.14.0, Copyright IBM Corp 2000, 2015. All rights reserved.
Compiled successfully.


---- Codesize ----
Codesize: 0 bytes
Robot weight class: NanoBot  (codesize < 250 bytes)

But it still doesn't show up. Something I noticed is when I look in the map of the sample bots they all have three files per robot. A .class, a .java and a .properties if I look in the map where my robot is in I only see a .java file. Maybe it has something to do with that?
Ps. I really appreciate your help.

Ian Tatters

unread,
Oct 20, 2018, 7:00:14 PM10/20/18
to robo...@googlegroups.com
I followed exactly this guide 
https://www.youtube.com/watch?v=JetqcHWcdwg
and still it doesn't work. A funny thing that I noted is that if you look at the message I got from the compiler it says Codesize: 0 while in the video it says Codesize: 58, so I think that somehow it doesn't register any code in it. Maybe I should download it again?

fnl

unread,
Oct 21, 2018, 1:14:31 PM10/21/18
to robocode
Hmm... it ought to work, when you use ECJ (Eclipse Compiler for Java), which comes with Java.

I discovered a bug with the Robot Editor, which does not save changes made to the file. Check that the } before run is indeed removed, if you examine the file in your /robot/irtatters folder.
If the misplaced character is still there, it could cause trouble.

Are you running with Robocode 1.9.3.3?

Best regards,
- Flemming

Ian Tatters

unread,
Oct 21, 2018, 5:32:58 PM10/21/18
to robo...@googlegroups.com
I think I found the problem. It is with the Robot Editor. After I read your reply which stated that it doesn't save changes I tried to change the sample bot fire to rotate it's gun left instead of right. I saved and compiled, but the robot still rotated it's gun right. So I think I need other tools to write my robot. What program do you use to write robots?
The } is not the problem. I just did exactly what the guide said me to do, so I didn't wrote any code and still it does nothing and yes I'm running Robocode 1.9.3.3.

fnl

unread,
Oct 21, 2018, 5:39:46 PM10/21/18
to robocode
If you run Robocode with Java 8 SE or older, the Robot Editor will work as expected. Java 9 made some changes that break the undo/redo functionality of the Robot Editor (and for other applications than Robocode).

But you might be better off with using an IDE like Eclipse, IntelliJ or NetBeans. If you want to use Eclipse, I have written an article about how to set it up here: http://robowiki.net/wiki/Robocode/Eclipse

Cheers,
- Flemming

fnl

unread,
Oct 21, 2018, 5:41:13 PM10/21/18
to robocode
By the way... the Robot Editor bug is fixed for the next version of Robocode (1.9.3.4). I will also add an updated Codesize tool too.

- Flemming

Ian Tatters

unread,
Oct 22, 2018, 2:57:44 PM10/22/18
to robo...@googlegroups.com
I applaud you for your patience and willingness to help! I use BlueJ for now and made it work! I finally can delve into robocode.
Thanks for all the help! 

--

fnl

unread,
Oct 22, 2018, 3:01:11 PM10/22/18
to robocode
You are welcome. I am happy that we solved the issue in the end... and I did find a bug that needed attention (Undo/Redo functionality broken when using Java 9).
So thank you for that. :-)

143050f...@gmail.com

unread,
Nov 21, 2018, 3:56:47 PM11/21/18
to robocode
I was getting the exact same problem! Omg it was so confusing. All the online guides made creating a robot seem so simple. Open editor, create new robot file, save, compile. I had no idea what to do since all the guides said the same thing, no one seemed to have the same problem in forums, and installing older versions didn't fix anything. One thing that I noticed is that every robot in the samples directory has a properties file and class file alongside the source code yet my own robot only has the source. I don't know if that's the root of the problem, but it seems to be a side effect :l when will that 1.9.3.4 be out? lmao 

Thanks

Ian Tatters

unread,
Nov 24, 2018, 4:44:16 PM11/24/18
to robo...@googlegroups.com
What I did, was installing BlueJ and after open a project go to preferences > libraries and then load the robocode.jar file. Now you can make a robot, to use the robot see the help page if you using another IDE.
Hope that this helps.

Reply all
Reply to author
Forward
0 new messages