Genetic Algorithm : Doodle Jump

Genetic Algorithm : Doodle Jump

The project consists of 2 main components: A minimalist Doodle Game type of game, playable by the user as well as by a genetic algorithm. The latter must improve the performance of a bot each new game.

Game Description

Doodle jump is a mobile game. The player controls an alien that needs to rise. Thus, he needs to bounce from platform to platform. The character bounces automatically and the player only needs to focus on the direction (left, right, stationary). There’s also enemies and special platforms, but because of a tight schedule, we couldn’t implement them.

Game Functions

We have three commands: Left, Right and Down (landing). We have a mid-air time, after which the player falls down unless he hits a platform to reset his mid-air time. Every time the player reaches a platform, the score increases, and the platform loses its ability to grant points. When the Y-pos of the player equals 0, the player dies.
The platforms are generated randomly but they still need to be close to each other to be reachable by the player. When the players reach a certain height, everything scrolls down and platforms that are below a certain height are modified so they reappear at the top. Click here to see a sample of the code

Genome

We created a 3x3x3 matrix that contains random float numbers [0;1]. They represent the probability of going left, right or down according to the X-position relative to the next platform and the mid-air time left. Click here to see a sample of the code.

Crossovers and Mutations

The crossover function generates a 3x3x3 matrix randomly filled with 0 an d 1 as a mask. It also generates an “inverted” mask by switching the state of each cells (0 to 1; 1 to 0). It then selects the two best players by their scores and applies the mask to them. Therefore, you will have 2 matrixes with blank cells that can merge into one complete gene.
The mutation function selects a random part of the gene and changes its value, it has 3 options to pick randomly from: no mutation, slight mutation or complete mutation. Click here to see a sample of the code.

Conclusion

Genetic Algorithms are powerful tools for the optimization of a function’s parameters. However, I think that backing it up with another type of Artificial Intelligence, such as a neural network or reinforcement learning, could help improve the performances even further.