Skip to content

Machine Learning 🤖 using a Genetic Algorithm 🧬 We will follow a set of ants that have to find their way to a juicy lemon 🍋 while avoiding viruses 🦠

Notifications You must be signed in to change notification settings

saifbechan/genetic-algorithm-v2

Repository files navigation

Genetic Algorithm - Saif Bechan

Genetic Algorithm 🧬

With the use of a genetic algorithm 🧬 ants 🐜 will find their way to a lemon 🍋 while avoiding viruses 🦠

Definitions

Population.Size >> the number of ants per generation
Population.Lifespan >> how long does a generation last

dna >> specifies the moves this ant will make
fitness >> specifies how well this ant performed

We start by creating a world and populate it with ants. Each ant starts with random dna and can only live a certain amount of time. When the time is over we will evaluate all the ants in the population and give them a fitness score. Based on this population we create a new population through mating. When creating a new population based on the previous generation there is also some mutation that takes place.

Schema

Genetic Algorithm Schema

Code

The most important part of the application lives in /game/sketch.ts. It is in charge of creating our population and displaying them on the canvas.

Installation

Make sure node is installed on your system. Use package manager yarn to install the application.

yarn install

Development

You can start the development server by running:

yarn dev

Stack

There are various libraries and tools used to make this application work.

next.js >> creates the website with React
p5.js >> creates the visualization

License

MIT

About

Machine Learning 🤖 using a Genetic Algorithm 🧬 We will follow a set of ants that have to find their way to a juicy lemon 🍋 while avoiding viruses 🦠

Topics

Resources

Stars

Watchers

Forks