January 2020 - Natural Selection Simulator


 Three months ago I have set out to create a new game every month using my free time outside the work. This month I have developed a simulation game that was heavily inspired by two sources. First inspiration source was the YouTube channel Primer and its natural selection simulations. The next inspiration came from Sebastian Lague's coding adventure: simulating an ecosystem.

For this project first I wanted to procedurally generate a world but I haven't done anything similar to that and I had no idea it would take almost all month for me to do it. So, I  researched the sources that I can learn it and decided to continue with Catlike Coding's Hex Map. I started to implement whatever the tutorial was saying day by day. But in a week I realized I wasn't getting anywhere, there was a long way ahead for creating what the tutorial was aimed.  Also I didn't even know how to create a very basic mesh with code. So, I went into the Catlike Coding's Procedural Grid tutorial. Learned to create grids and using Perlin noise for bumps. Then I made this ugly piece of dirt.

First attempt to create a surface, January 7

After this I realized I could make a voxel world and voxel animals and it would look just fine. So, i tried to create a cube with what I learned. Next day I could create one side of the cube.

One side of cube with no UV, January 8

Then qucikly I managed to create a cube with 6 sides but only problem was I created the cube with only 8 vertices because I thought that would be enough. 

My first cube with 8 vertices and unlit material, Januaray 9

I was wrong because I couldn't put UV on it properly. Because there was only 8 vertices. I realized it after seeing this:

Trying to put UV on my cube with 8 vertices, January 10

So, I searched for an easy tutorial to teach me how to make a proper cube. Then I found this tutorial on creating cube in Unity. It was really helpful. I quickly implemented it and created my cube with 14 vertices that has a proper UV. But there was  a problem, 14 vertices turn out to be not enough for properly showing the UV.

My 14 vertex cube that looks like there is a shadow on it, January 12

Because 14 vertex cube didn't get proper lighting I learned my lesson and started to create my final cube which has 24 vertices which turns out to be the norm. At the beginning I learned Unity's default 3D cube had 24 vertices but I though I was going to make a cube that has higher performance with lower vertex number. I was wrong.

The quickly I made my first 24 vertex modular cube that I could remove any sides that I want while creating and I could put any texture on by just passing the cube type at the beginning.

My eventual 24 vertex modular cube, January 15

After accomplishing this simple task in half a month I started to make it into a grid of cubes and gave it perlin noise to make them look like a land.

My first attempts at creating a voxel world, January 16

There were small errors because there were gaps in the map. I quickly fixed that. Then I started giving colors to my land. I first searched for how to create bioms and it was a little complex and frankly I didn't have enough time for anything at this point. So, I just went with coloring the cubes according to their heights.

Colored land, January 18

This looked fine to me but there were couple of problems. First being the generation time which would take three minutes to create a 500x500 map. Second problem was giving higher elevation. My system didn't support that. The last one was edges of the map was empty and looked ugly.

Example of final state, January 21

One of the most important things that I learned through experimentation was quickly generating a huge map with high performance was about generating the map in tiles of medium sizes. If I were to generate whole map as one huge mesh, it would take forever to generate but I would get a very high fps in play time. So, I thought maybe I should  just generate one map and save it to use it later but that is not the point of procedural generation. If I were to generate every cube separately I could generate the world very fast but I would get a very poor performance. So, I did what I learned from Catlike Coding's Hex Map tutorial an made my map in tiles. The smaller the tile size, the higher the performance but the lower the generation speed. Then I decided to make my 100x100  maps in 5x5 tiles and it worked like a charm.

Additionally, I was creating the whole mesh from scratch when I was adding a cube to a tile. I realized it very late. Removing this error gained my more than 60x performence. While I was generating a 500x500 tile in 3 minutes, I could generate it in 2.7 seconds.

Last state of the map with threes, plants and animals

After finishing the map I was left with a week to complete my natural selection game. This required a nature simulation that I had to write in a week. My first thoughts about the game was creating a more complex simulation with campaigns and etc but with the time I have created a sandbox simulation where two animals can be created and put in the wild to see who will outlive the other.

My chicken and other weird creature, January 30

It was hard to finish the project on time, I had to scope it down very much. In the end I could publish it only 5 minutes left to the February.

This month I learned and had fun a lot. This turned out to be my most popular game on itch.io and I loved the project that is why I will continue to develop this into a better simulation. Hope you will enjoy it too.

If you liked the game and my devlog. Please follow me on itch.io so that you will see the better games that I will develop in the coming months.

Files

NaturalSelection-Win.zip 21 MB
Jan 31, 2020
NaturalSelection-Web.zip Play in browser
Jan 31, 2020

Get Natural Selection Simulator

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.