Light-Cycle KotHLight-Cycle KotH
Basically the light-cycle game as a KotH competition.
The Game
Players will write bots that compete in a light-cycle arena. A round of light-cycle starts with bots randomly spaced out along the edge of a (tentatively 10x20) rectangular play area:
+--------------------+
| @ @ |
| |
| |
| |
| |
| |
| |
| |
| |
| @ @ |
+--------------------+
Each turn, each bot simultaneously must choose one of 4 directions to step (N/E/S/W). A space that was once occupied by the "head" of the bot becomes part of the "body" of the bot.
+--------------------+
| # @# |
| @ |
| |
| |
| |
| |
| |
| |
| @ |
| @# # |
+--------------------+
The round ends as soon as one or more bots crash into a wall, or into the head or body of another bot (including its own head/body).
*CRASH*
+-----------@--------+
| # ##### |
| ### |
| # |
| @ |
| |
| @ |
| # |
| # @# |
| # ### |
| ## # |
+--------------------+
The bot(s) that crashed into the wall will be removed, and the game will start again with new starting positions. (If multiple bots crash on the same turn, the most-recently submitted bot will be eliminated and the others will survive) (Update: If multiple bots crash on the same turn, they will all be eliminated)
Bots are eliminated each round, until only 1 bot remains. The leaderboard rankings are based on the order that the bots are eliminated.
Code / API
For ease of judging and creating the online platform, submissions will be restricted to javascript.
A bot is a javascript function with the following API:
(state) => {
// state is an object with access to information about the game
// bots can use the state to make decisions
// bots return one of "N", "E", "S", "W"
// e.g.:
return "N";
}
The state
variable contains the following API calls:
state.getDim()
: Returns a[w, h]
tuple of the width and height of the arena. e.g.[20, 10]
state.getSelf()
: Returns a[x, y]
tuple of the current bot's head. e.g.[3, 7]
state.get(x, y)
: Given integersx
andy
, returns a string corresponding to what is currently on the map at (x, y)"#"
- body of a bot, or out-of bounds of the map ("wall")"@"
- head of a bot" "
- empty cell
(Coordinate system: The bottom-left-most cell of the play-field is (0, 0), with x increasing to the left and y upwards)
Code submission
I plan on making a GitHub repository containing the source code for the judge. The repo will include an HTML file so that it is possible.
Submissions will be made by making a PR to the repo to add their bot's source code (in addition to posting the submission as an answer, of course!)