Loading...

Cellular Life Simulation

I created this project of a cellular automata simulation of simple life for my Design Patterns course. It simulates the behavior of plant and animal like organisms, each represented as a colored pixel.

They use chromosomes to decide the attributes of the organisms that undergo random mutation and crossovers during reproduction to simulate the evolution of traits. Each species of animal can only reproduce with it’s own kind, and compete against each other for food resources, which are the plants.

The design patterns implemented in this project are:

  • Composite Pattern: To compose world objects using components that define the behavior of the object.

Composite Pattern UML Diagram

  • Builder Pattern: To dynamically assemble objects using multiple components such as a draw component for rendering and specific Animal and Plant components to define the behaviours and reproductive capabilities.

Builder Pattern UML Diagram

  • Abstract Factory: To create families of organisms and plants that are instantiated for the simulation. The factories internally use the builder to assemble organisms.

Abstract Factory UML Diagram

  • Iterator Pattern: To iterate through all the world objects to perform simulation actions.

Iterator Pattern UML Diagram

  • Visitor Pattern: To visit each world object and collect data about the simulation to log it for analysis.

Visitor Pattern UML Diagram

Github Link