[Home]SnippetBot

Robo Home | Changes | Preferences | AllPages

This is the one bot that I think to be the grandfather of so many of todays bots. I know allt of my bots can trace their lineage directly to it. Jekyl started with this code base and grew from there. The tutorial and code can be found at http://www.ecs.soton.ac.uk/~awo101/robocode.html Mirror: http://lhs.fuhsd.org/staff/peck_george/notemplate/robocode/SnippetBot/robocode.html. Who else derives their code ultimately from here. I know Paul says his bots do too. Anyone else? -- jim

The basic idea of design (do your thing in the mainloop and keep event-code short) and some parts of the targetting code will be used in the next version (0.6) of GrubbmOne. My old stack of code, you can't call it a design, was skipping too much turns. You can't blame me however, I'm just the new grandpa on the block . . . -- GrubbmGait

Well, my bots certainly does not inherit a thing from this one. Why would doing stuff in the main loop and keep the event code short be desirable? I do it the opposite way. Only because it is easier for me to do so. -- PEZ

You're less likely to lose ScannedRobotEvents? if you do it that way. At least that's the theory. Almost all my code is in my main loop too. --David Alves

I guess I could move most of my code there. Though I don't think I know the execution order of things well enough to do so. Besides, my bots seem to work as they are. =) -- PEZ

If you're losing ScannedRobotEvents?, at least your bot will still do something during that tick because most of the code will be in your main loop. Although it will operate on data that's a timeframe too old, that may still be better than not doing anything at all. --Dummy

uhm... actually I'm not very sure anymore... if you're missing ticks, do you miss events, or will you always skip the entire turn? --Dummy

Maybe someone can test this? I would, but my plate is full getting my RR@H server up. --David Alves

I've read that you get your events the next turn if you skip only one turn, but that you lose them if you skip more turns in a row. No experimenting yet... -- Jonathan

@Jonathan: Yeah that's my understanding. I meant test whether it's better to have your code in your event handler or main loop. But for that matter it would be good to test under what conditions you can lose events. I don't think anyone knows for sure. --David Alves

My fault, my bot was not skipping turns, it just hardly executed the mainloop. Cause of this was the remnant of TrackFire, which uses 'turnGun..' and 'fire' in the scan-event. This caused my bot to get glued to the wall sometimes, because the 'wallmove' code resides in the mainloop. -- GrubbmGait

Lol, SnippetBot has a HUGE spike at GF 0.0 and pretty much nothing else greater than 0.2...but it is still useful as an example for code structure (of course, for 'simple' bots)--Starrynte

Anyone else notice there are some errors on the SnippetBot tutorial? Look at this page: [1].

(target.name == e.getName())
just doesn't seem like good things to be teaching new Java programmers. I think someone should rewrite the SnippetBot tutorial on the wiki -- Aziz

          String a = "hello";
          String b = "hello";
          System.out.println(a == b);

This will likely print "true". I haven't tested any of this. The following will likely output "false":

          String a = "hello";
          String b = a + " world";
          String c = "hello world";
          System.out.println(b == c);

However

System.out.println(b.equals(c));
will print out "true" always. The equals(Object) method is a method defined in the Object class. It doesn't really do much, but most classes implement it. For example, the String's equals() method may compare the string character-by-character to test if it is equal to another. Google it more to find out. Java's == operator is not overloaded for any objects, and it ONLY tests if references are equal. BTW, the following will print "true":

          String a = "hello"
          String b = a;
          System.out.println(a == b);

This is because the object reference b has been set to the same object as a, in this case, the String object "hello". When comparing object refences using ==, it tests to see if the references point to the same objects on the heap memory. And actually, you shouldn't assume that it will work. If the code in Robocode is changed in the future in a way that the name setting is implemented the same way, or the Java compiler/JVM changes, you're robo is busted ;) -- Aziz


Robo Home | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited May 22, 2008 7:45 EST by adsl-69-110-145-236.dsl.pltn13.pacbell.net (diff)
Search: