Saturday, March 29, 2025

A Competitive Coding Game Where Players Write Arbitrary Code

I wanted to think of a two player game where players write arbitrary code on their turns, and then compete to achieve some objective first. Here's what I've come up with:

As a sort of pie rule, player 1 picks an integer, and then player 2 gets to decide if they take the first "coding" turn, or if player 1 gets to instead. Let's say player 2 decides to do the first coding turn.

They then write a function that takes any and only integers and returns for each some other integer, and they put in their own integer, and it must output the integer that player 1 picked. Now player 2 must do the same thing.

Player 2 gets a score which is the number of programming "tokens" (like "while" or "max") used in the function's definition. The length of the input integer in base 2 is also added to one's score. Any other explicit numbers in one's definition are also actually counted for their length in base 2 when scoring, and not just as one token. Also, each time say player 1 uses a token or number that player 2 also used in their last code, an extra point is added to player 1's score.

After this, player 2 gets to put their own input integer into the function that they just wrote, and they get a new integer. Now player 2 must write another function that outputs that same integer using the same rules as before, and then player 1 must. Things keep going back and forth like that. You play to say, 200 points, and whoever reaches 200 first loses, as the goal is to write simpler code to output the target integers.

So far I've only tried playing with ChatGPT using a coding plugin, and ChatGPT played some rather uninspiring moves that were not very difficult to defeat. But I still think that the game could be interesting.

A Game Based on the Non-Periodic "Einstein Tiles"

The "Einstein Tile" is a recently discovered shape, where repeating just one of these shapes makes a non-repeating infinite pattern. I decided to try coming up with a game based on this tile. 

Players take turns putting Einstein tiles down on the board. One player is the “grower” and the other the “stopper”. The grower tries to make as large a pattern as they can, while the stopper tries to stop them (there are ways to play the tiles such that new tiles cannot connect. You have to put them down just right if you want them to actually grow forever.) Experimenting with other constraints have helped to make the game work better: after tile 1, new tiles must connect on 3 or more edges. After tile 2, tiles must also, additionally, connect with two or more tiles that are already down, simultaneously. Also, no putting a tile down such that it leaves a hole in the growing tile pattern.

Then the players switch roles so the other is the grower and the other is the stopper, and you see who can get a larger group before stopping, as the grower. Or you could play first to 200 points or something.  

I've played a few games of this with other people, and we thought the game was fun. It often seemed the stopper was so close to closing everything off, but one leftover part of the board would find a way to continue, until it couldn’t any more. Simple strategies are just to think of ways to play that stop other plays and play those a lot, or to find places where a tile can be played in 2 ways and play the better / worse way for future growth.

 An almost finished game: