Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Particle System with Genetic Algorithms with Processing

Notifications You must be signed in to change notification settings

ClaudioDavi/genetic-particle-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Genetic Particle System

A Prey and Predator simulation with genetic algorithms powered by Processing and Java.

DEMO 1

Introduction

Due to my recent interest in genetic algorithms, I decided to create my own take on the famous algorithm Game of Life from John Conway.

His idea for generating a life-like pattern for life followed four simple rules

  1. For a space that is 'populated':
    1. Each cell with one or no neighbors dies, as if by solitude.
    2. Each cell with four or more neighbors dies, as if by overpopulation.
    3. Each cell with two or three neighbors survives.
  2. For a space that is 'empty' or 'unpopulated'
    1. Each cell with three neighbors becomes populated.

Those rules alone were capable of creating very interesting patterns as seen in the gif below taken from Wikipedia. If you want to know more about the original game of life (It's a very interesting read). Please follow the link

Game of Life

Life Rules

For my take on the game of life I created a few rules:

  1. Default Rules
    1. If you touch another 'life form' the bigger one survives
    2. If you see someone bigger than you, you run away. (Prey Behaviour)
    3. If you see someone smaller than you, you hunt. (Predator Behaviour)
  2. Game Rules
    1. If there are only 5 life forms available, a new generations is born.
    2. If More than 2000 cicles were complete, a new generation is born.
    3. If you touch the wall more than 50 times you die. (Preventing wall exploits)
  3. Generation Rules
    1. Each generation is created from the most fit parents chosen using a monte carlo approach.
    2. The fitness is calculated using the following:
      • Each cicle alive wins 2 points
      • Each action taken wins 1 Point (Follow or Run)
      • F = (Cicle + Action)/10
    3. Each parent has 50% chance of spreading one of its genes for every gene in the pool
    4. Each life form has it's own attributes that can be inherited including: size, acceleration, force, velocity, awareness distance and so on.

DEMO 2

Next Steps:

  • Clean the code (There is a lot of unused code in there).
  • Improve readbility.
  • Create more complex behaviours.
  • Use reinforcement learning.

About

Particle System with Genetic Algorithms with Processing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published