Robots can implement the following functions:
import gamefile
Your robot must import gamefile, this allows it to interface with the arena and the other robots
def colour(): return(0,0,0)
The colour() function returns an RGB tuple of the form (R,G,B) where R,G and B are numbers between 0 and 255. The editor has a function built in to the robot menu which allows you to change the colour
def commands(): gamefile.turn_right(deg) gamefile.turnleft(deg) gamefile.move(frames) gamefile.stop(frames) gamefile.fire() gamefile.done()
The commands() function interacts with gamefile and allows the robot to move, turn, fire and stop
"frames" denotes how many frames the movement will last for, for example gamefile.stop(5) would be stopping for a very sort period and gamefile.move(400) would me a very long movement
if a turn function is called immediately after a stop function, the robot will stop before turning, otherwise the robot will turn while moving.
for loops can be used inside the commands function.
if statements are also supported, however there may be problems if they rely on values that could change midway through the commands() function's execution, for example a global variable that is changed by target_spotted.
health = gamefile.robotHealth()
this optional function will, when called within the commands function return the health of the robot, this can be very useful for changing behaviour under different conditions
def target_spotted(direction): gamefile.pointgun(direction) gamefile.fire()
this function will be called whenever the robot's radar spots another robot, it will return the value direction which you then have to handle, it is recommended to use the gamefile.pointgun(deg) function to tell the robot to turn its gun towards the newly spotted enemy. Then gamefile.fire() will cause the robot to shoot a shell at the target
def startDirection(): return deg
This optional function allows you to define the starting direction you wish your robot to be pointing in when the arena is set up
if any questions about how to use the software remain, feel free to look at the robots already built to see what functions they use.