Inspiration

Cellular Automata are a super cool form of in-memory computing, where the information which is stored (the grid state) is in the same place the computations are performed. I wanted to explore the possibility of using cellular automata as a "brain" for an agent in some sort of environment. I landed on Pong because it's relatively simple to understand, and has very few inputs & outputs.

What it does

Attempts to "evolve" a 5x5 kernel which can play pong using the grid configuration. The world state is input on the left, and the motor regions are defined on the right of each grid. Each kernel is rewarded based on its activity in pong, and the best kernels are moved to the next generation (and mutated)

How I built it

Everything is written in python. All of the game states, actions, etc... are written using numpy (since it's basically all matrix multiplication) and all the graphics are rendered using pygame.

Challenges I ran into

I was planning on using the NEAT algorithm to evolve the kernels, but NEAT networks are very sparse. Which resulted in most kernels at any point to be empty. I would like to revisit the idea of using NEAT at some point in the future, but I overcame this challenge by writing my own genome, selection, and mutation functions.

Accomplishments that I'm proud of

The evolution algorithm uses no libraries, and I wrote all of it myself. It's still missing a few components such as crossover and speciation but I managed to implement the bulk of it!

What I learned

Got way more familiar with numpy, this was my first time using it properly and it is such a useful library. Also a lot on genetic algorithms since I had to write it myself rather than using an existing framework like NEAT.

What's next for Cellular Automata Plays Pong

Implementing speciation and crossover to push kernel exploration further!

Built With

Share this project:

Updates