Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coffeeeatnight/genetic_algorithm_maze_solver
Utilizing evolutionary algorithms to mutate agents gens so they are able to find the best possible way through a maze represented as a 2D matrix written in Nim
https://github.com/coffeeeatnight/genetic_algorithm_maze_solver
Last synced: 18 days ago
JSON representation
Utilizing evolutionary algorithms to mutate agents gens so they are able to find the best possible way through a maze represented as a 2D matrix written in Nim
- Host: GitHub
- URL: https://github.com/coffeeeatnight/genetic_algorithm_maze_solver
- Owner: CoffeeeAtNight
- License: mit
- Created: 2024-09-09T14:18:14.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-09-10T07:31:20.000Z (4 months ago)
- Last Synced: 2024-11-09T08:12:44.997Z (2 months ago)
- Language: Nim
- Size: 134 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🧬 Genetic Algorithm Maze Solver
### A simple genetic algorithm project that evolves agents to navigate a 2D maze! 🚀
---
## Overview 🎯
This project implements a **genetic algorithm (GA)** to evolve agents that can find their way through a maze. The agents start with random movements, and through natural selection, crossover, and mutation, they gradually improve their ability to reach the goal.
Key Features:
- **Genetic Algorithm Core**: Includes selection, crossover, and mutation mechanics.
- **Maze Representation**: The maze is represented as a 2D grid with walls, paths, and a goal.
- **Real-time Visualization**: Watch agents as they evolve in the maze with a simple ASCII representation.
- **Elite Selection**: Top-performing agents are selected as the basis for the next generation.---
## How It Works 🧠
1. **Initialization**:
- Agents are created with a random genome (sequence of moves: up, down, left, right).
- Agents are placed at the start position in the maze.2. **Fitness Evaluation**:
- Each agent’s fitness is determined by how close it gets to the goal. The closer, the better the fitness.3. **Evolution Process**:
- **Selection**: The top-performing agents (elite agents) are selected to reproduce.
- **Crossover**: Two parents’ genomes are combined at a random point to create offspring.
- **Mutation**: Some offspring may experience small random changes to their genome to introduce variation.4. **Next Generation**:
- The new generation replaces the old one, and the process repeats until agents successfully reach the goal or the set number of generations is reached.---
## Maze Layout 🗺️
The maze is represented as an 8x8 grid:
- **#**: Wall
- **A**: Agent
- **G**: Goal
- **(Blank Space)**: Path---
## Todo:
- **Fix problem where generation stops after some time**
- **Improve fitness function to prevent local maximum**
- **Integrate OpenGL to better represent generations**---
![image](https://github.com/user-attachments/assets/e8d83414-d388-45f2-ac5b-3571967c034d)