I was playing with the browser canvas to render a few pixels and wrote a simple 2d game inspired by breakout. I thought that would be a good excuse to try the genetic programming code from the previous post.
It did work. The resulting expression is not as graceful as a human playing and the movements have a bias towards the left x position of the paddle but it does the job.
In the next iterations I’ll expand the variables fed to the expressions. Currently, only the ball and paddle x positions are exposed. Adding the blocks and opponent positions can in theory yield more strategic expressions.
In order to make it more entertaining I’ve added a table with scores and the expressions from the player and the opponent in use.
In a real world use case no rendering is necessary and the matches can be parallelized. Nonetheless, it’s entertaing to watch the matches and follow the evolution of the expressions.