Wednesday, April 15, 2009

Robot Battle – the Dead Target Robot

Robot battle is a game that requires you to write programs to make the robots battle it out for supremacy. The robots have the same physical features; the program (the robot brain) is the only feature that decides the winning robot.

A distinct programming language called Robot Scripting language (RSL) is used to control the actions of the robot. The documentation included with the game is good enough to start writing your own robots (.prg files).

I just created a Dead Target Robot for doing target Practice. The Sample program created using the documentation included with the Robot Battle game defeats Dead Target Robot easily.

Source of Deadtarget.prg:

#The dumbest robot ever. Just sits and waits to get killed. Good for target practice.
Init
{
name( "Dead Target" )
author( "Nagarjun V" )
version( "0.1" )
}

Source of Sample.prg:

# Init section sets up robot and registers handlers
Init
{
name( "Sample" )
lockgun( true )
regcore( MyCore )
regdtcrobot( FoundRobot, 1 )
}

MyCore
{
# if scan finds a robot, the event handler runs
scan( )
radarright( 5 )
}

# scan detected a robot, shoot at it then check again
FoundRobot
{
fire( 1 )
scan( )
}

The results of a game between the above two robots:

Name

Points

1st

2nd

Sample

40

20

0

Dead Target 0.1

0

0

20

No comments: