An engine/API for programming Snake bots and pitting them against each other
Copyright (C) <2011> <Arian Jafari, Sixten Hilborn, Erik Thuning>
Version 0.2
NOTE - This step is only for those who are interested in modifying the source code. The program can be run by simply double-clicking the 'snaykuu.jar' file
Compilation of the program is done with ant.
Using your terminal, navigate to the snaykuu
directory and run the command
ant jar
. This compiles the code and creates an executable jar file, which
can then be executed either by double-clicking it or running ant run
.
Bots are compiled separately.
With ant, bots are compiled using the command ant bot
.
If you don't have ant installed, navigate to the directory where your snaykuu.jar
is located, and then run this command:
# javac bot/*.java -cp snaykuu.jar
The essence of writing a SNAYKUU bot is simple. Your bot is a java class
implementing the interface Brain
, requiring a single method called
getNextMove()
. This method will be called once each tick of the game, and is
where you calculate in which direction you want your snake to move next. Each
tick you are given a GameState
object, which is a detailed representation of
the current state of the game, also containing several useful methods to assist
you in the coding process.
Much more detailed information can be found in the API in the doc/
subdirectory.
Start the program by either double-clicking snaykuu.jar
, navigating to the
snaykuu directory and running java -jar snaykuu.jar
in a terminal, or by
running the ant run
command if you have ant installed.
When you first start SNAYKUU, you will see two lists in the middle of the
screen; Snakes in game and Available snakes. Available snakes contains
a list of all the compiled classes implementing the Brain
interface. By
double clicking the name of a bot in the Available snakes list, you can
add/remove it to the game. When you want to start the game, press the
Start button.
In the Game settings tab you can manually select which settings you want to play with. These are your options:
After a game has been played, you are given the option to save a replay of the game at hand to be able to view later. If you want to view a saved replay, simply click Replay tab, click the "Load an old replay and play it!" button, and use the built in file browser to find your .srp replay file.
Note that replays saved in older versions may not be compatible wth your current version.
In the developer mode, you can run any number of 'simulated' games much faster than running them individually with graphics. To use dev mode, begin by selecting the participating snakes in the snake selection screen. Then, navigate to the developer tab, select the number of games you want to be simulated, and then click Run test games. The program will freeze for a while while the simulations are running.
When it is done, a menu will pop up containing statistics and data from the simulations.
This screen is fairly straight-forward. The snakes show up on the screen, ready to rumble! Fruit objects will occasionally show up on the board, and it is up to the snakes to reach them and devour them.
On the right hand side of the game board is a live-updated score board of the current round. Snakes are shown, identified by name and color, together with the number of fruits they have eaten and the number of turns they have survived.
After a game has finished, a new window displaying the results of the game will pop up, together with some options. The score board will be nearly identical to the one that is shown during the game, showing the scores of all the snakes as well as their placement in the round. Together with this, four buttons will appear: New game, Rematch, Save replay and Exit. This is what they do: