Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arduino88/evolutionary-dots
A simple pygame genetic-algorithm project simulating evolution of dots to find a path around obstacles to a goal.
https://github.com/arduino88/evolutionary-dots
evolutionary-algorithm genetic-algorithm machine-learning mutation numpy pathfinding pygame python3
Last synced: 11 days ago
JSON representation
A simple pygame genetic-algorithm project simulating evolution of dots to find a path around obstacles to a goal.
- Host: GitHub
- URL: https://github.com/arduino88/evolutionary-dots
- Owner: Arduino88
- Created: 2024-05-11T02:02:02.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-05-13T19:30:07.000Z (9 months ago)
- Last Synced: 2024-12-04T12:11:55.285Z (2 months ago)
- Topics: evolutionary-algorithm, genetic-algorithm, machine-learning, mutation, numpy, pathfinding, pygame, python3
- Language: Python
- Homepage:
- Size: 1.99 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Evolutionary Dots
A personal project inspired by the one and only **[Code Bullet](https://www.youtube.com/@CodeBullet)****This is my first foray into the world of numpy-only genetic algorithms**
#### Overview
In this program, a group of dots are released into an environment with walls and a goal object.
The dots have simulated velocity and acceleration, as well as an input list of acceleration vectors, used as "genes", subject to mutations and natural selection.![](https://github.com/Arduino88/Evolutionary-Dots/blob/main/evolutionary-dots.gif?raw=true)
#### In each run:
- The dots iterate over their respective list, setting their acceleration to the contained vector, and checking for collisions.
- Once every dot has either died or reached the goal, their fitnesses are calculated:
- fitness = 1 / (distance to goal) ^2.
- if touching goal, fitness is multiplied by the remaining steps in the list (incentivizes more efficient paths).
- if dead (collided with wall or screen border), divide fitness by two.
- Then, a new set of dots are created, with a probability of having a dot as a parent proportional to the parent's fitness (fitter dots are more likely as parents).
- Randomly, for each child in the new dot set, A gaussian noise distribution is calculated and applied to existing vectors.
- This is controlled by a mutation rate variable, with a low probability of an individual vector being mutated.
- The best dot is saved from the previous run, and is added to the next generation to prevent detrimental mutations regressing progress (This is the green dot).
- All dots are re-initialized at the beginning of their acceleration list, and placed at the shared starting position.
- The next run is initiated.