Game of Game of Life
Conway's Game of Life is a 0-player game. But that's okay! We can make it a multi-player game.
This game is played on the smallest square grid that will accommodate a 6x6 square for each player (12x12 for 2-4 players, 18x18 for 5-9 players, etc). This grid is actually a torus, so it wraps in both directions. The rules of Life are:
- If a cell has exactly 3 neighbours, it comes to life (or remains alive) in the next generation.
- If a cell has exactly 2 neighbours, it does not change in the next generation.
- If it does not have exactly 2 or 3 neighbours, it dies in the next generation.
A cell's neighbours are those cells adjacent to it orthogonally or diagonally; each cell has 8 neighbours. In this game, there are only a few differences from the standard Game of Life:
- Each player has a different colour of life, with dead cells being white and neutral living cells being black.
- When a cell becomes alive, it takes on the colour of its most common neighbour, or black (no player) if there are three different colours. Cells do not change colour as long as they are alive.
- Each generation, each bot can cause one nearby cell to come alive in their colour or one of their own cells to die. This happens before a generation is processed; a cell that is killed may come back to life and a cell brought to life may die in the subsequent generation.
Winning the game
The game lasts 1000 generations, or until there is only one colour of living cells remaining. If all coloured cells die on the same generation, the game is a draw, and no bot receives points. Each bot scores points equal to the percentage of living coloured cells it has at that time (out of the total number of coloured cells). 10000 games will be run, and the winner is the bot with the highest average score. Ties are broken with a 1v1 cage match.
Starting conditions
Each bot will start with the following layout of living cells:
......
......
..##..
..##..
......
......
These will be randomly arranged into the square playing area. Each 6x6 area without a bot will have the same configuration, but with black living cells.
Bot parameters
Your bot will be written in Javascript, and will not have an average call time of over 50ms (bots that do may be disqualified, but bots may use performance.now()
to police their own time). It will accept as parameters:
grid - The grid on which the game is played. This should not be modified.
botId - The bot's ID, corresponding to the colour on the grid.
lastMoves - An array of each bot's most recent move, as it's (usually) possible but computationally intensive to get this information otherwise.
Your bot will return an array with two elements, x and y. This is the cell that your bot wishes to play. It must be within 2 cells of one of your living cells. If the selected cell is alive and not one of your cells, it does nothing unless the bot whose colour it is removes it on the same generation, in which case it causes it to be your colour. If it is alive and one of your cells, that cell is killed before the next generation. If it is a dead cell, it comes alive before the next generation (it comes alive as your bot's colour unless some other bot also picks it, in which case it comes alive black).
A play too far away from one of your cells is a pass. Alternately, [-1,-1] is an explicit pass. A play off of the board in any other way is illegal and grounds for disqualification.
On the grid, -1 is black (neutral living), 0 is white (dead), and all other numbers are the id of the bot whose life is in that cell.
Other Restrictions
- You may make a maximum of 3 bots.
- If your bots uses random numbers you can use
Math.random
. - Your bot may, if it wishes, store data on
this
. It will be cleared between games. - You may not make a bot which targets a single, prechosen bot. Your bot may target the tactics of a class of bots.
- Cooperation is legal between bots, but communication is not - you can cooperate with a strategy, but not attempt to make a specific sequence of moves which identifies your bot. For example, identifying a bot based on specific starting sequence is not allowed, but knowing "target bot prefers moving up and left, all else equal" is okay. IDs are randomized and bots will not know in advance what other bots' IDs are.
Controller
This isn't quite complete, but it's a good start. I plan to keep track of scores, add a box so it's easy to test a new bot, etc. Of course, some of that is hard to test without real competitors, but I'll get around to it.
It seems that I made x the major axis and y the minor one, so if your bot is going a different way than you expect, that might be why. Sorry.
Example bot
It seems traditional to include a bad bot in the competition to get things started. This bot is bad. It chooses uniformly at random from cells in the grid and tries to move there. I haven't yet had it survive 1000 generations.
function randomMovesBot(grid, botId, lastMoves){
return [Math.floor(Math.random() * grid.length), Math.floor(Math.random() * grid.length)];
}
Winner
Two weeks after the last new submission (or a significant change to a bot), I'll close this by running 10000 games (number subject to possible revision). I'll leave the controller up afterward if someone wants to make a new submission, but official standings won't change.
bots
array. \$\endgroup\$