Giter VIP home page Giter VIP logo

evolutionary-fish's Introduction

Evolutionary-fish

Fish schools based on the boids algorithm that evolve through an evolutionary algorithm.

Description

The goal of this project was to evolve species of fish in a hostile environment consisting of sharks. In order to accomplish this evolution, it was developed an evolutionary algorithm that prioritizes the number of living individuals in each group of fish.

Boids

To simulate the behavior of a fish school, each specie was implemented based on the boids algorithm developed by Craig Reynolds. In short, the boids algorithm is ruled by three conditions : alignment, cohesion and separation.

Alignment

The alignment rule states that an individual should point to the average direction of its neighbors. The following gif shows a fish school that only has the alignment behavior. The gray semi-circle represents the observable range of the black fish and the black lines at front of each fish represents the direction it is pointing towards.

Cohesion

The cohesion rule states that an individual should go towards the mass center of its neighbors. The following gif shows a fish school that only has the cohesion behavior and the red circle represents the mass center of the black fish's neighbors.

Separation

The separation rule states that an individual should avoid its neighbors when they are close. The following gif shows a fish school that only has the separation behavior and the red area represents the avoidance range of the black fish. For this specific project, the avoidance range was developed to be small than the visual range of each fish.

Alignment, Cohesion and Separation

In this way, it is possible to simulate a similar behavior of fish schools using the alignment, cohesion and separation rules.

Evolutionary Algorithm

Population

The population is composed by species of fish. Each specie is represented by a class named Boid, which has the following main characterists :

  • alignmentWeigh
  • cohesionWeigh
  • separationWeigh
  • avoidSharkWeigh

These variables range from 5 to 100 and they represent the genes of a specie. There are also other variables that define the color of the fish in the Boid class, but they are only for aesthetic purpose and don't influence on the boid's behavior.

Fitness Score

The fitness score is the sum of seconds that each fish survived. More specifically, a boid fitness score is calculated by the following equation :

Fitness Score = โˆ‘ seconds fish_i survived

in which fish_i represents the i-th fish of the boid.

Evolutionary strategies

For this project, it was used the elitism, variable mutation and random predation techniques to evolve the population.

Elitism

The elitism consists of taking the best individual (boid) of a generation and crossover it with every other individual. To perform the crossover between two individuals A and B, it is only necessary to calculate the mean values between each gene of A and B.

Variable Mutation

A normal mutation vary some or all genes of an individual by a fixed percentage value. Meanwhile, a variable mutation is basically a normal mutation that can change this percentage value depending on some situations.

Random Predation

The random predation consists of taking the worst individual (boid) of a generation and substitute it with a complete random individual.

Links

For details about the evolution analysis and a better explanation of the evolutionary methods : analysis

For details about the installation : installation

Here is a video briefly explaining the whole project (in Portuguese) : video

evolutionary-fish's People

Contributors

kenzonobre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

skn123 taresusenu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.