things I do

Serial Gaming

Website - Github

I’ve had a couple of Raspberry PI pico at home for years, mostly unused, but recently I’ve wanted to try something with one of them.

I’ve created a simple TicTacToe game in javascript, and used the WebSerial interface, that only works in Chrome, to make a pico play the game using some micropython code that I wrote.

I then wrote and tested different AIs, all running on the very limited hardware of a pico (264kB RAM and dual-core Arm Cortex-M0+ CPU): a random one, one that uses MinMax to decide the next move, one that learns each game which move is best given the current situation, and one based on a perceptron.

The random one is, of course, the least strong one. MinMax is strong, but I had to reduce the number of steps it will precompute: given my bad code, the low power CPU, and the use of python instead of C, it took almost a minute to make the first move.

The one that learns while playing is really fast: it saves and loads its memory on a simple json file that, given any board situation, will return for each possible move how many times it won or lost using that move. Then uses softmax to choose a move, given priority to winning moves. At the end of each game, it will update its memory.

The perceptron one was pretrained instead, and it’s a really strong opponent.

Where to go now?

I have 3 things I want to implement for this project:

Chess

Just like with TicTacToe, but chess, with a few AIs of gradually increasing complexity, always with the limitations of the RP2040.

Pong

I don’t know if WebSerial and RP2040 will be enough to build an AI that plays Pong without lagging and at a good level, but it’s something that I’m willing to try.

Competition

My original goal is to create a competition where everyone can send (or bring, if in person) their RP2040 powered AI and make it compete against another one.