Ant Farm Simulator

2017

C#, Unity, Blender, AI

This project arised from my love for ants. Having studied ants as a hobby and by analysing their behaviours in an antfarm, I decided to make an ant farm simulator on Unity Engine. My love for video-games and interest in developing them peaked my interest in this engine due to its more friendly learning curve compared to Unreal Engine. By choosing this language, it also meant that I had to program the behaviours and scripts in C#, which was an excelent way for me to get familiar with it.

Having had some classes where I had to use Blender, I took upon myself to create the models for my 3D game. This was by far the biggest solo project I worked on and my first time dipping my toes into AI and 3D environment.

Challenges

  • Make complex algorithms
  • Time constraints must be respected
  • Modelling the entities
  • Entity interactions
  • No previous experience in AI design, 3D development and Unity

A happy little colony.

AI

Because this is a simulator, the entities living in this world must try to reenact real life. For those who don’t know anything about ants, there are two main castes: The queen and the workers.

The queen’s job is to lay eggs and stay alive. She doesn’t do anything else and is dependant of her workers. The workers’ job is to guarantee the colony’s survival. This goes from brood tending (ants lay eggs that develop into larvae and then pupae), hunting, cleaning, hauling/stockpiling and feeding each other and the queen. All of these behaviours were implemented in this simulation plus a running away behaviour if a predator was found. Below we can see the implemented behaviour tree (State Machine diagram).

Behaviour tree of the ants.

3D to 2D environment representation

Ants communicate through pheromones (a secretion that ants release with various scents used for communication; different scents, different meanings) and I wanted that to also happen in the simulation. To do that it was needed to represent the 3D environment in a 2D grid to be able to store their pheromones. On startup, the game divides the 3D scenario in chunks and verifies if the chunk can be pathed by an ant. If it can, it will create a position in a 2D array that is ready to hold different pheromone values.
The map ended looking like this:

2D grid and 3D map.

Pheromone spreading through the playable area.

Due to propagation of the pheromones throughout the scenario, the ants act more natural and have different reaction times depending on the distance to the origin.

Queen Care pheromone spreading through the nest to recruit more idling ants.

Final thougths

Nowadays, years after dropping this project behind, I can still say that this was one of the most important ones I’ve done due to all technologies involved, complexity and challenges faced. It allowed me to grow a lot technically and made me much more proactive exploring new ideas.