Natural Selection Simulator

AI Visualizer

Role

Full Stack Dev

Duration

1 week

Tools
Unity C#

Overview

As I discovered the ins and outs of Unity and interactive design during my internship at Infina, I had the idea to create a natural selection simulator using artificial intelligence. I had seen similar projects before, but wanted to create my own from scratch to learn a bit more about AI and the Unity engine.

Ideation

What questions would this project answer?

Objective

The first step was to decide what exactly this simulation was going to show. I had a rough idea of what I wanted to implement: AI controlled bots simulating the natural processes of organisms, i.e. eating, reproducing, passing on genetic traits, etc.

Problem

My main goal was to easily convey these features as cleanly as possible, so I had the idea to make the "organisms" simple AI-controlled cubes that roamed around. They would each be equipped with a simple UI canvas showing their energy level and their sex. The organisms' speeds would be conveyed by their color (blue and red corresponding to slow and fast, respectively). The food sources would be represented by green spheres, which would repopulate if in a specified "feeding area."

Other Challenges

As I started formulating ideas on how to implement these features, I realized that if I were to simulate a believable population, I would need to account for some other factors. For instance, food consumption, energy management, reproductive drive, and genetic variation were all things I was going to have to implement in the backend.

sim notes

Implementation

Creating the visualization

Mockups

I wanted the program to be as lightweight and intuitive as possible, and to reflect these principles in the visual design of the application. I created a quick mockup of what the layout would look like, and created a palette for the ten possible speed groups. ​

wireframe
agent design

Design

The UI of the program was designed to be as minimal and nonintrusive as possible. Two graphs on the left side of the screen allow for the user to view the current distribution of male and female organisms in the population, as well as the distribution of speeds among them. The user also has the ability to pause or fast-forward the simulation. ​

final

The Result

The organisms were coded to each have traits within a set of predetermined parameters to simulate the surfacing of optimal traits among the population. Ultimately, the tradeoffs between speed and energy consumption, paired with the limited availability of food, resulted in a preference for a more moderate speed gene. The blue colored (1-3 speed) organisms tended to die out, as well as any fast organisms (7-10 speed), which would eventually perish due to their increased energy consumption. Over repeated trials, it became apparent that this pattern was repeating itself, resulting in controlled population sizes as well a much higher number of midrange speeds (4-6).

Reflection

Working on this side project gave me a lot of insights on best practices for tackling design and development problems. I can't stress how important it was to ensure I knew what and how I wanted to create certain aspects of the application before I actually dove into implementation.

The project also provided insights on how to best approach fullstack work in general. I had no collaborators on this project, so the design and development work was all on me. Flying solo in a project means a lack of critique and external perspective, so that's one area this project suffered in. However, it helped me learn that iteration is vital, and catching errors earlier on in the process rather than later helps a project's timeline as well as the quality of the final product itself.

Recommended 🔎