-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This is public information that is shared with the public.
The public API consists of a Maven project with the API and an example project that implements a stupid snake brain. To follow this guide you need the following:
- JDK6
- Maven 2
- A Mercurial clone of the source directory on or a downloaded zip with the source code.
Before you come to the venue for the competition, make sure to run the builds of the provided example brains as described below. Maven requires quite a lot to be downloaded to build the projects and this will make the (somewhat shaky) WLAN at the venue more available for other tasks.
The easiest way to implement a brain is to follow the steps below:
- Unzip the source code or clone the repository to <SOME-PATH>/crazysnake-api
- Open a terminal window and enter the crazysnake-api/api directory
- Enter the following at the terminal: mvn clean install
- cd to crazysnake-api/<lang>-brain of your choice.
- Open up crazysnake-api/<lang>-brain/pom.xml in a text editor of your choice. Change any entries with your-team-name-here to your registered team name. This makes it easier for us to keep teams deliverables separate.
- Enter the following at the terminal: mvn clean install
- You should now have a complete brain, packaged as a jar-file in crazysnake-api/<lang>-brain/target/your-team-name-1.0-SNAPSHOT.jar This resulting .jar-file can be used by our game engine to incarnate a snake with your brain and make it part of the game.
General rule - Play nicely!
By this we mean that nobody will be happy if you try to make the game run bad by for example doing something like:
- Calling System.exit()
- Spawning new threads
- Write to disk
- Allocate a huge amount of memory
- And so on...
If you feel hesitant about something being allowed or not, it is possible to ask us but most likely the answer will be that it is not allowed to do any funky stuff.
We will also reserve the right to inspect the code of the winning brain before accepting it as a winner. We will also reserve the right to publish the code of your brain implementation.
Your brain will have a dedicated thread of execution for a specified amount of time (50 ms) when getNextMove() is called. If your brain does not respond within this timeout it will automatically move forward until it is responsive again. You will have the possibility to test the responsiveness of your brain on our hardware on the competition day.
Inside the crazysnake-api/<lang>-brain project is a src-directory that contains the brain implementation. If you wish to change the class-name of the brain you must ALSO modify crazysnake-api/<lang>-brain/src/main/resources/META-INF/services/se.citerus.crazysnake.Brain so that the line inside this file contains the name of your Brain-implementation.
Currently, we have successfully implemented brains in Java, Scala, Clojure and Groovy. We will provide example projects for these languages. If you wish to use a different JVM-supported language, please let us know and we will do our best to make it work.
During runtime, we will provide some third-party libraries and language libraries for your convenience. We will not support bundling of other third-party libraries. Since the provided libraries are provided by our game engine, you should not bundle these inside your jar file. Use the example brain-projects provided and you will be fine.
The following libraries are provided at runtime:
- commons-lang.commons-lang (2.5)
- org.clojure.clojure (1.2.1)
- org.clojure.clojure-contrib (1.2.0)
- org.scala-lang.scala-library (2.8.1)
- org.codehaus.groovy.groovy (1.7.10)
This is an overview picture of the rules of the game. For details, consult the Javadoc or send an e-mail.
The snake that eats the most fruit wins the game. Each fruit gives the snake 1 point. If the number of points is shared between two snakes, the snake that died last will win over the snake that died before.
When the head of a snake collides with either another snake, its own tail or a wall it is considered a lethal collision and the snake will die.
When a snake collides with a fruit, it is eaten and the snake scores a point.