The Robo Battle Pigs AI Challenge is based on the standard, two-player version of RBP. Each player provides an AI script that is evaluated each round, and the script must produce a legal set of moves for the pig. Specifically, the result of the script:
In order to keep the pace of the game moving, a turn limit is
introduced to the game. Each challenge will have a specified
turn limit.
Your AI scripts must be written in the
BeanShell language.
The very last statement in your script must evaluate to a
string, and this string must contain an encoding of commands
that are valid for your pig.
We use the standard encoding presented
at the Robo Battle Pigs homepage.
There are eight variables that are set prior to your script's
being executed:
We use the standard commands and encodings presented
on the
Robo Battle Pigs web site, listed here for convenience.
All commands are with respect to the direction the
pig is facing.
Below is a sample script for an articial intelligence that chooses
random moves.
(Download the script.)
In fact, this is the same script that is executed
if you select "Integrated AI: Random AI" in the RBP game.
Here is another sample script for a rather dim-witted AI that sits
in one place and shoots. It turns out that this AI is rather effective
against the random AI given above.
Clearly, this is not a good technique in general: consider the excitement
of a game where this AI is played against itself!
Script Format
Command Encodings
Sample Scripts
String randomCommand() {
// Math.random() returns a random double between 0 and 0.999...
// Multiply by 8 and cast to an int, and we should have a num in [0,7].
int n = (int)(Math.random() * 8);
switch(n) {
case 0: return "^ ";
case 1: return "\\ ";
case 2: return "/ ";
case 3: return "TL ";
case 4: return "TR ";
case 5: return "v ";
case 6: return "F ";
case 7: return "H ";
default: print("This should never happen.");
}
}
// This will hold the result
String result = "";
// Make sure we have one Damage(X) command for each wound
int i;
for (i=0; i<5-health; i++)
result += "X ";
// All other commands are random
for (; i<5; i++)
result += randomCommand();
// The last thing in the script must be the command string.
result;
// This will hold the result
String result = "";
// Make sure we have one Damage(X) command for each wound
int i;
for (i=0; i<5-health; i++)
result += "X ";
// All other commands are Fire(F)
for (; i<5; i++)
result += "F ";
// The last thing in the script must be the command string.
result;