You probably know Conway's Game of Life, the famous cellular automaton invented by mathematician John Conway. Life is a set of rules that, together, allow you to simulate a two-dimensional board of cells. The rules decide which cells on the board live and which ones die. With some imagination, you could say that Life is a zero-player game: a game with the objective to find patterns with interesting behavior, like the famous glider.

A zero-player game... Until today. You are to write a program that plays the Game of Life - and plays it to win, King of the Hill-style. Your opponent (singular) of course tries to do the same. The winner is either the last bot with any live cells, or the player with the most live cells after 10000 generations.

Game rules

The rules are almost the same as normal (B3/S23) Life:

A live cell with fewer than two friendly neighbors dies from starvation.

A live cell with two or three friendly neighbors survives.

A live cell with more than three friendly neighbors dies from overpopulation.

A dead cell with exactly three neighbors of the same player comes alive to fight for that player provided there are no enemy neighbors.

...but after each generation, both you and your opponent get the opportunity to intervene. You can awake up to a maximum of 30 cells to fight for you. (Who goes first is decided by the server.)

The board is a (x,y) cells square. All squares are initially dead. The borders do not wrap around (this is not a torus-shaped world) and are permanently dead.

This is is a contest in the spirit of Battlebots and Core Wars. There is a central server that will run bots and it can be found here

Scoring

This question has been in development since 2014 and was the most upvoted question in the sandbox. Special Thanks goes to Wander Nauta (original author and concept), PPCG Chat (comments and help) and anyone who commented in the sandbox post (more comments).

I can't believe that after all my work setting up block-making switches for indefinite growth and a system specifically built to demolish growth structures, a simple exploder-based system bested mine in combat :o
– Value InkMar 7 '17 at 22:40

I don't know how it does either, because I can't run the controller for whatever reason.
– MagentaMar 8 '17 at 7:50

Ruby, InterruptingBlockMaker

Instead of initializing gliders like the TrainingBot, it tries to create a 5x5 block-making switch machine as mentioned on Wikipedia at a random point in the maze. Then, with its remaining activations, it just finds enemy points and tries to pepper the nearby area with your cells in an attempt to interrupt them from growing and possibly messing up their patterns. Your cells will die in the next generation, but maybe they also stopped some growth to slow down your opponent!

v2: Optimized slightly (?) to try to minimize timeouts.

v3: Optimized interruption code to pre-sample a subset of active blocks before rejecting our own cell locations, to prevent timeouts further at the cost of some effectiveness in the interrupt cell attacks.

@muddyfish thanks, that fixed it! Now the only issue is that Windows command line commands have a hardcoded limit of 8191, which means that at a certain point in the simulation the bots will crash from being unable to parse the truncated JSON string. It's an OS issue, so I guess I have have to look into a Linux cloud box or something in order to test my bot~
– Value InkJun 29 '16 at 21:09

@muddyfish I already mentioned that Windows has problems because of the command line limit, that last error was on Cloud9 which is ostensibly a Linux box. How does my bot fare on your Linux box (since you implied that you had one)?
– Value InkJun 29 '16 at 22:45

Turns out I hadn't committed it but the numbers in bot_score show how many wins each bot has against other bots
– BlueJun 30 '16 at 21:11

All right, thanks! Unfortunately, Cloud9 indeed does not have a GUI and Windows still can't run the simulation without breaking its command limit eventually, but at least I got a brief look into how the bots fare against each other. Also, I get to see my bot fight against itself to the end some times because they keep attacking each other and preventing enough growth to break the character limit, although it does time out occasionally...
– Value InkJun 30 '16 at 21:33

Java, Troll Bot

Troll Bot has thought about it, and he realizes he does NOT care about the enemy. In fact he just spams these factories to produce more of his guys randomly all over the map. After a while he realized that any additional cells are best used in clumps. These blocks of four cells will stick together and stop gliders in their tracks! He does not think he just fights. Also he is a big supporter of verbose object oriented programming. The troll also assumes that coords are in the format y,x, and he is asking to be tested. Just put him in a file called "TrollBot.java", and he'll be set!

Python 3, RandomBot

This bot has trouble making intelligent decisions, but it at least knows not to try to place things on top of other things. It'll randomly create gliders, boats, C/2 Orthagonals, and 2x2 blocks with various orientations, ensuring that when they're placed they're not overlapping with something else, ally or enemy.

This bot wasn't tested, seeing as I'm receiving all sorts of errors when I try to run the GUI. Also, I used the TrainingBot as the base and just edit, so any similarities in code is probably because of that.

The GUI is most likely failing because of your print(sys.argv[1]) on line 3, which messes up the output (the simulator expects only the string of coordinates you want to wake up). Also, the last line of your program is missing a closing paren.
– Value InkJun 30 '16 at 22:56

@KevinLau-notKenny The GUI was failing on the training bot and the Ruby bot as well. I removed that line, though, and added back in the closing paren (I think that latter one was a copy-paste error).
– Steven H.Jun 30 '16 at 23:04

What operating system are you on, and what errors appear in the command line when you run it? Currently it's a known bug that Windows cannot properly run the sim because of arguments passed through command line being truncated when they exceed the command line character limit of around 8000.
– Value InkJun 30 '16 at 23:21

@KevinLau-notKenny I'm using Windows 10, and I've gotten... well, a lot of errors. The first thing was BeautifulSoup not wanting to find html5lib, then not finding the folder containing all the bots (I had to change the code for both of these), and since then the running of either Python bot has resulted in a non-0 return code 1.
– Steven H.Jun 30 '16 at 23:24

Windows still can't run the code if there are too many active cells on the screen... But as for your other errors, it might be because TrainingBot wants Python 2?
– Value InkJun 30 '16 at 23:27

Your Answer

If this is an answer to a challenge…

…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.

…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.

…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.

More generally…

…Please make sure to answer the question and provide sufficient detail.

…Avoid asking for help, clarification or responding to other answers (use comments instead).