Genetic Smart Rockets


Genetic Smart Rockets

This project was completed by Myself, Erie Adams, and Nicholas Robinson, as the final project for our Artificial Intelligence Practicum.

The goal was to create a game-like program where users could edit the attributes of the rockets in attempt to see how different factors effect Genetic Algorithms. Users can alter: mutation rate, speed, number of agents, and turn frequency.

The rockets then must complete different mazes, forcing the user to improve their parameters - thus enforcing their understanding of the algorithm. The fitness function was the most difficult aspect of this project. We settled on using a distance and time based function - rewarding rockets that got close to the goal quickly. We also used many different mating strategies, settling on each rocket getting 1/2 of its 'genes' from either parent (randomly chosen from most fit agents). The 'genes' are acceleration vectors which the rocket follows post spawn, and are chosen: odds from parent 1 and evens from parent 2. Rockets were limited to 50 genes - thus extremely long courses are not viable.

Source Code
Fitness Functions

We tried many fitness functions to determine the 'success' of each rocket. For example, minimum distance to target, shortest time to target, least 'genes' used, etc.

We found that a combination of minimum distance and minimum time worked best. We added a large multiplier to those rockets that did reach the target. This ensures that the rockets converge on a successful set of 'genes' very quickly once a few succeed.

Mutation Rate

Mutations were a tricky aspect of the project. Many different mutation rates seemed to work well. This goes against the common notion that faster/more mutations would cause the rockets to succeed faster/more frequently. However, this did not seem to be the case (at least on the limited amount of maps we tested on).

Thus, we chose to let the user alter this as well, and simply start it at a successful default value, which we determined during testing.

More about the project

To the right is the hardest map. This took our best rockets over 200 generations to complete.

A large breakthrough in getting the rockets to train faster was to implement a pseudo memory. Allowing rockets to have checkpoints, which if they made it to, would lock their genes. This removed the need to relearn earlier parts of the course, and drastically decreased the number of generations it took to complete harder mazes.

Our statistics:

  • Easy maze: ~ 12 generations
  • Medium maze: ~ 50 generations
  • Hard maze: over 200 - very irratic.
  • Spiral maze: immpossible - did not deploy this to users - took thousands of generations to complete.


Tools Used

  • Languages:
    • C#
  • Technologies:
    • VS Code
    • GitHub
    • Unity
  • Tools:
    • Fitness Func
    • Mutation rate
    • Mating style
    • 2D physics
    • Colliders