Growing Pains (Making a Game – Part 3)

This time: less of a dissertation, more pictures! I’ve been working on getting the grass to, well, do things. As previously mentioned, I had thought to try to somewhat mimic Conway’s Game of Life, but departed from that relatively quickly. Instead, I came up with some initial assumptions about how grass should behave:

  • It doesn’t move, but it can grow to adjacent spaces.
  • It will grow when it has enough energy, and will die if it runs out of energy.
  • Growth reduces energy.
  • It doesn’t live well in isolation, but it also doesn’t thrive when crowded.
  • All behaviors should include some variance.

Gotta Start Somewhere

Before implementing any behaviors, I had to do some figuring-out how to get the grass to interpret the game state and make copies of itself, which is mostly boring. Instead, here are a few early failed tests:

This one also caused Unity to crash!


The above made me realize that the square boundary I had drawn didn’t have any application yet in how the game understood itself, so I ended up just making the whole background brown and have delegated “game boundaries” to be a future problem to solve.

Also at some point between the above two tests I did manage to create a state of equilibrium; the grass was not yet growing, but it was dying in a relatively random – but ordered – way.

Like, Mold or Something?

The equilibrium test was nice because it was demonstrating some of the assumptions I had made. Since it dislikes crowding, the grass would die if there were too many other adjacent grass tiles. However, this was a bit much. Plants don’t tend to just fully die because there’s other plants around, plus in future tests it just looked very inorganic, so that behavior was greatly reduced.

Next I reached a stage where the grass actually appeared to grow:

This was good! I then thought it would be neat to visualize the “health” of the grass:

This is the first point where I thought “Oh, neat!” My main issues here are that A) grass in isolation was dying far too quickly, and B) the growth was very uniform and uninteresting. Groups of grass close enough together would simply amalgamate into a big blog and grow outward with little variation.

Something Not Entirely Unlike Grass

At this point, the internal workings of the grass had quite a lot of settings to fiddle with. And fiddle I did. For a couple days. Until it reached its current state, which I’m quite happy with:

The biggest differences between this version and the previous are that it is much more likely that grass in isolation would stagnate rather that die, and that a piece of grass would not always choose to grow to an adjacent square when it had enough energy to do so. This led to a great deal more variation in the patterns that grew. It still does trend in the direction of a solid blob, but that’s more of a function of there being nothing to curb its growth; there’s infinite energy for it to grow with, and nothing to eat it.

For fun, I also made a GIF with the same settings but double the size:

One thing you might notice near the end of that one is that the frame rate starts to noticeably drop. If I let it run much longer it absolutely crawls. So, I will definitely need to put in some work optimizing the current processes. Every individual grass square probably doesn’t need to be acting every frame, eh?

What’s next?

I still have a few things I’d like to do with the grass, such require growth to take time, and, as mentioned, I need to try to optimize the speed a bit. After that, though, the next two additions I want to make are some sort of herbivore creature and water. These will introduce something for the grass to consider food, and something to consume the grass.

Leave a Reply

Your email address will not be published. Required fields are marked *