Monday, September 13, 2010

07.Robocode

Robocode is an open source educational game that Professor Johnson has introduced us to in ICS413. It was originally developed by IBM to show the capabilities of Java in supporting a 2d game engine. However, since leaving the hands of IBM, it has evolved into a great utility for others to learn Java.

The objective of 07.Robocode, introduced by Professor Johnson, was to introduce the class to the experience of actively learning a new java system along with its respective API. We also had to get used to working with the Eclipse IDE along with refreshing our knowledge of intermediate Java.

The objectives of the 12 robot designs are as follows:
  • Position01: The minimal robot.  Does absolutely nothing at all.
  • Position02: Move forward a total of 100 pixels per turn.  When you hit a wall, reverse direction.
  • Position03: Each turn, move forward a total of N pixels per turn, then turn right.  N is initialized to 15, and increases by 15 per turn.
  • Position04: Move to the center of the playing field, spin around in a circle,  and stop.
  • Position05: Move to the upper right corner.  Then move to the lower left corner.  Then move to the upper left corner. Then move to the lower right corner.
  • Position06: Move to the center, then move in a circle with a radius of approximately 100 pixels, ending up where you started.
  • Follow01: Pick one enemy and follow them.
  • Follow02: Pick one enemy and follow them, but stop if your robot gets within 50 pixels of them.
  • Follow03: Each turn, Find the closest enemy, and move in the opposite direction by 100 pixels, then stop.
  • Boom01: Sit still.  Rotate gun.  When it is pointing at an enemy, fire.
  • Boom02: Sit still.  Pick one enemy.  Only fire your gun when it is pointing at the chosen enemy.
  • Boom03:  Sit still. Rotate gun.  When it is pointing at an enemy, use bullet power proportional to the distance of the enemy from you. The farther away the enemy, the less power your bullet should use (since far targets increase the odds that the bullet will miss).
  • Boom04: Sit still.  Pick one enemy and attempt to track it with your gun. In other words, try to have your gun always pointing at that enemy.  Don't fire (you don't want to kill it).
Each of the robots provided their own unique challenges, but none took too long to implement. The trickiest part of the whole experience was having to learn how the robots work with bearings and the trigonometry functions needed to navigate the map. Most notably, I had to remember which functions returned radians and which returned degrees.

During the development of the simple robots, I was able to effectively utilize the Eclipse IDE. It provided great interfacing with the javadocs associated with the Robocode project. The means to implement the methods were described by the respective javadocs.

I used the sample robots for general knowledge on how to use the Robocode methods to meet the criteria for the assignment. These could be found in the Robocode installation package. Sample robots, such as the Tracker robot, provided great insight in deciphering method usage as the names of the robots provided intuitive knowledge of what to expect in the source code. The tracker robot tracks, the spin robot spins, and so forth.

The whole process felt very smooth. Whatever errors I encountered were usually displayed/flagged by Eclipse. These could generally be quick-fixed by proper selection from the recommendations provided. Thus, I believe I was able to meet the criteria for all 12 robots. The compressed Java project for 07.Robocode can be found here:


Since developing these sample robots, I now have a decent idea of where to go when designing a competitive robot. I will most likely use the Tracker robot, provided in the Robocode samples, as a template. I am confident that I can now at least create a Robot that will defeat: Walls, RamFire, SpinBot, Crazy, Fire,  Corners, Tracker, & SittingDuck as required by 09.CompetitiveRobot.

No comments:

Post a Comment