Giter Site home page Giter Site logo

anuraghazra / evolutionaquerium Goto Github PK

View Code? Open in Web Editor NEW
179.0 5.0 22.0 373 KB

:fish: :bug: Small Inteli Creatures Based On Steering Behaviours

Home Page: https://anuraghazra.github.io/EvolutionAquerium

License: MIT License

HTML 9.26% JavaScript 83.09% CSS 7.66%
genetic-algorithm canvas2d simulation flocking-simulation boids steering-behaviours flocking-algorithm flocking flocking-agents agent-based-simulation

evolutionaquerium's Introduction

Evolution Aquerium

Check out Evolution Aquerium case study.

Try Out The demo

Craig Reynold's

Check-out DevEnv Branch for Beta Optimization and Development which includes Refactored Code and EcoSystem.js Class to manage Creatures and Easy-to-use API for making new Agents.

How It Works?

Well that's an obvious question.

These Creatures are based on Craig Reynold's Steering Behaviors and Flocking System

It's also implements Genetic Algorithm and mutations.

You can learn more about them on Daniel Shiffman's YouTube Channel The Coding Train

How My Code Works?

My code is actually pretty simple.

Agent Class

I made a Agent class which handles all the Basic behavior like

  • flock()
  • align()
  • separate()
  • cohesion()

And added some basic parameters like

this.radius = radius; //size of the agent

this.health = 1; // health 

this.healthDecrease = 0.003; // how much health will decrease over time

this.goodFoodDie = 0.5; // food increase the health by that amount 

this.badFoodDie = -0.4; // poison decrease the health by that amount

I also added a sex variable for the agents and all of them also has unique names

this.sex = (Math.random() < 0.5) ? 'male' : 'female';

Fear Behavior

And for the most important part, i added a defineFear() method which handles Fear behavior.

It's a robust function to define fear which can be also used inversly with negative values.

defineFear() function allows Agents to add Steering Forces simultaneously on each other

// list, weight, perception, ?callback
creature.defineFear(predators, -4, 50);

Reproduction System

Reproduction System checks for male and female agents and if their radius is greater than 8 and they are close enough to each other, then they can reproduce with their specific DNA and creates a small Agent based on their DNA data and with some mutation.

Predator class

Predators are simple but deadly they just has a sex property set to 'predator'

and i used defineFear() function inversely to attack the Creatures

And bigger they get slower they became.

Avoider Class

Avoiders are very very very fast but they are very agile too. they just has a sex property set to 'avoider'

and i used defineFear() function to avoid every poison and Predator.


Have Fun Watching Them All Day

Try To Contact Me

I AM A PROUD INDIAN.

evolutionaquerium's People

Contributors

anuraghazra avatar imgbotapp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

evolutionaquerium's Issues

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.