Once our team hit the development stage and started implementing our plan, one issue quickly reared its head – performance. Our evolution simulation simulates thousands of species living, reproducing, and dying – which means thousands of objects needing thousands of calculations every tick. In our first implementation, we quickly found out that our original model didn’t work. Well, it did, but for all of 30 seconds before my computer froze and the Unity Editor crashed.
It was something we hadn’t really planned for, but we had to deal with regardless. If we can’t run the simulation, we can’t test out mechanics in the simulation. So we had to get to fixing. I took the lead on this, and researched ways to analyze performance in Unity. Fortunately, it wasn’t difficult – the Unity Editor has a built-in Profiler that tallies function calls and reports their relative percentages. It helped me track down the most demanding functions – creation of new genomes, and a constant UI refresh. I fixed the UI performance hit on my end, and relayed the genome issue to the teammate in charge. Problem solved!
…Not so fast. After applying the fixes, our simulation ran for about 10 seconds longer, before it started to chug again. Another look at the profiler revealed new issues – a naming function, UI updates for thousands of entities, and more. We had to fix those as well. And more. And more. In the end, we had to spend a good chunk of our time for 3 weeks optimizing before the performance became serviceable, and we are under no illusion that that’s the end of the story. The experience gave me some perspective into why it often takes so long for video games to get optimized – it’s a hard task, and there’s no way around it.
Leave a Reply