[Home]SimpleRobot

Robo Home | Changes | Preferences | AllPages

SimpleRobot will be a helper class to simplify the use of Robocode-Robots. A SimpleRobot gets input each tick, process the data and returns an output.

Idea

The design of Robot and AdvancedRobot is very confusing to me, so I decide to create an easy interface. It seems to me, that the Robots are made for realtime battle, but the battles are no realtime battles. Battles are computed in ticks and every Tick the AdvancedRobot can set some output (setXXX) and get some input (getXXX). The output will be performed when execute() called, which calls tick() from RobotPeer? ( the real base of all Robots ) It would be easier to create good Robots, if the Robot gets all inputs at beginning of a tick and returns all outputs at the end of a tick.
That might look like:
Output run(Input) {...}

A list of the minimum needed information for a Robot which I found out until now:

Outputs

acceleration
bodyturn
gunturn
radarturn // ignored for Droid
bulletpower // 0 if no bullet should be fired, ignored if gunheat > 0

Internal states

position:(x,y)
velocity
bodyheading
gunheading
radarheading // if radar exist ( Droid )
energy // <0 means dead, 0 means disabled
gunheat
Iterable<event> refilled after last processing

Inputs

position:(x,y)
velocity
bodyheading
gunheading
radarheading
energy
gunheat
Iterable<event> occured between last turn and this turn

Threads

I don't know if threads are allowed, but they work which allows processing "old" data between ticks without taking the risk for a skipped turn, but if the GUI needs much CPU time ( resizing, moving other windows over battlefield ) the Robots gets a skipped turn ).

Robocode

Robocode could change it's implementation to this simple form. The base of all Robots should use a RobotPeer? private! Every extended Robot can offer methods, which allows an easier use to write small Robots, like "move N pixels forwars", "turn N degrees left" and event handling ( which aren't real events because the game runs in ticks ).
The result could be:
RobotBase? ( uses RobotPeer? ) // offers simple input/output methods
AdvancedRobot extends RobotBase? // offers event handling and advanced movement method
Robot extends AdvancedRobot // offers very easy methods to control the Robot
which would allow, that every Robot or AdvancedRobot runs like before.

Future

An implementation of a SimpleRobot will be shared.

Robo Home | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited November 8, 2006 23:14 EST by Sin Varg (diff)
Search: