EcoSim Timeline


Overview

EcoSim is the first project I’ve worked on since finishing college. The main goal I had for EcoSim was to tackle a sizable project that didn’t have an externally enforced deadline, practicing the habit of working on games after work and committing to seeing the project through to an end. I also wanted to further get better at C++ and programming in general by doing more of it. The high concept of the game was originally planned to be a simulation game where you earn currency by keeping plants and animals well balanced and stable. You can then use that currency to add more things to your ecosystem.

Oxygine Initialization

I wanted to write in c++ and do a lot of the work myself for practice purposes, so I didn’t want to use a game engine like unity. However, I also didn’t want to spend time dealing with graphics boilerplate and implementing core stuff like an event system. So I found a framework, oxygine, that I could use for graphics, input handling, and events but would still let me do everything else in c++. The first thing I did was set up the git repository for the project. After that, I set up the most basic possible use of oxygine: a sprite that changes color when you mouse over it.

Basic Grid

Next, I wanted to add a 2d grid, as I knew the game would be grid based. I also added a very simple version of plants that grow and spread.

Button Pipeline

At this point, I wanted to start making things controllable during the game, which meant buttons. I made a handful of buttons manually in paint.net before concluding it would be way too tedious to do this for the entire project. So I made a simple script that uses image magick to automatically generate buttons from art.

Tiles and Plants

Next I added an ability to control the simulation speed as well as the ability to visualize values on tiles and plants. These features would be necessary to flesh out tile and plant functionality

After that I added more complicated plants. Grass only has two stages, so I added berry bushes which benefit from a particular type of nutrient in tiles (red/blue) and have 3 stages.

Next, I added buttons to spawn the plants. Before this, I would just programmatically spawn in the plant I wanted to test as a quick thing hacked into my initialization functions.

After adding buttons to spawn plants, I generalized the spawning system a bit so it could be expanded on in the future to spawn different types of entities.



Animals Part 1

After getting plants in a decent state, I started to work on animals. Because animals don’t have stages like plants, I felt that visual feedback was important to have an idea about how healthy a particular animal unit is. So I made a sort of totem that would have four dynamic parts. First, the animal icon in the middle. Second, the food type (herbivore, omnivore, carnivore) icon below. Third, the background of the food type icon would communicate whether the population is currently increasing or decreasing. Finally, the sides would indicate the current population. The sides being empty indicates the animal is about to die and the sides being full indicates the animal is about to split into a new unit.

I didn’t really like my initial plant sides, which were supposed to be bands. I replaced them with leaves and while I was working on it anyway, I improved the sides for carnivores as well.

After getting the animal dynamic assets fully working, I implemented herbivores actually eating plants.

Gui

Although herbivores functionally worked, the simulation was completely unstable. Even in the final version it’s pretty unstable but it was really bad when I first implemented herbivores. They would eat out any plant almost immediately then have nothing else to eat and die. I naively expected the range of stable values to be much bigger than it actually was. Also, I was having these issues with only herbivores. I hadn’t even added the additional complexity of predators yet. I was pretty discouraged by this because I just didn’t want to do the large amount of design work that would be required. I was discussing this with a friend of mine who suggested I pivot the game plan from simulation game to just a sandbox with all the dials available to the user. I was hesitant at first but ended up agreeing it was a good idea and switched my plan to that.

As I always do whenever I need a gui, I used ImGui. Oxygine’s OpenGL setup was a bit weird so it wasn’t as completely painless as it’s been in the past but it was pretty easy. Big fan of ImGui.

Animals Part 2

Once I was more easily able to edit animal properties, I was able to find a more stable set of numbers. Although it still isn’t great, it’s much better than it was. After fixing herbivore numbers, I finished up animals by adding omnivores, carnivores, and flying animals.

Monoliths

At this point I had the complete simulation of animals eating animals and plants finished. The last thing I wanted to add were Monoliths, which modify simulation properties in an area around them. In the picture above, that monolith prevents things from spawning in its area.

World Generation

One of the last things I wanted to do was improve the world generation. Before this point, it would just randomly roll each individual tile. I wanted to add an algorithm that lead to a world with larger patches. I found a relevant stack overflow that I modified a bit and it worked pretty well.



Conclusion

I’m definitely not super happy with the final output, but I still think it was a solid project. One last thing I tried to do was port it to web but that didn’t work out. I will talk about that and the things I learned that in EcoSim Postmortem.

Thanks to Dylan Tice Carroll who came up with the idea to pivot to a sandbox and Nolan Yoo who helped me from time to time with technical problems.