Log In  

Cart #evolvingants-0 | 2024-05-07 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

This is a very basic implementation of a genetic algorithm, partly inspired by this Code Bullet video, with a few additions to improve the evolution speed and reliability. It's nothing fancy, but I found it fun to experiment with, so I thought I'd share it.

Each "ant" has a DNA consisting of a list of directions to move each frame, which starts off completely random, but though the process of mutations and "natural selection" evolves into a path to reach the goal.

To improve the evolution speed and reliability, the ants are evolved gradually by giving each generation slightly longer to reach the goal. In addition, the mutations to the DNA are biased towards the end of the path, so more ants have a chance to explore the end of the path before they die.

The simulation consists of 50 ants in each generation, with the current best path shown in red. Pressing X will restart the simulation with the goal in a random position.

P#148057 2024-05-07 14:30


[Please log in to post a comment]