Skip to content

Cells find their way to a target using a genetic algorithm.

Notifications You must be signed in to change notification settings

saifbechan/genetic-algorithm

Repository files navigation

Genetic Algorithm

With the use of a genetic algorithm cells will find their way to a specific target while avoiding obstacles.

Definitions

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

Cell.dna >> specifies the moves this cell will make
Cell.fitness >> specifies how well this cell performed

We start by creating a world and populate it with cells. Each cell starts with random dna and can only live a certain amount of time. When the time is over we will evaluate all the cells in the population and give them a fitness score. Based on this population we create a new population through mating (cells don't usually do this but in our world they do). When creating a new population based on the previous generation there is also some mutation that takes place.

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

Cells find their way to a target using a genetic algorithm.

Resources

Stars

Watchers

Forks