Avoiding Unintended Consequences

Published by Tom on

The past few weeks I’ve been focusing on improving creature physiology. The basic implementation of creature bodies is finished, but they have a surprising sensitivity to the parameters of their environment and to how evolution is implemented in code.

As an example, a few months ago, I adjusted the drag of water (the amount that it pushes back against motion) to be proportional to the square of the speed of the body part moving through it; previously, it had been directly proportional to the speed. This is more realistic and made swimming motions more fluid. Creatures have a love-hate relationship with drag: it slows them down but they rely on it to propel themselves forward in the first place. Some time after making this adjustment, I noticed creatures evolving very muscular bodies and very tiny limbs, the size of fingers. This allowed them to whip their tiny limbs back and forth as quickly as possible, generating extremely large forward propulsion from the (now-squared) drag velocity. This seemed to be such a dominant strategy that it was rare to see a species NOT do it.

Even something as simple as a bug-fix may have multiple possible approaches, each of which may affect how creatures turn out. So I decided to take a more scientific approach. For every change to the global parameters of the world or the evolution code itself (things that are likely to have knock-on effects on creatures), I now leave the game running overnight: it simulates a population for twenty generations, saves an exemplar individual to disk, and then repeats the process. This way I can generate a large set of creatures for any potential change to the code. After generating a set of ‘control’ creatures with no adjustments, I load them all into a test environment that spawns each one in a random order (so I don’t know which creatures had which adjustments) and prompts it to be scored on a one-to-ten scale for its overall aesthetics and swimming style. After scoring several hundred creatures, I can graph the average score of each bank and add the changes that improved the creatures to the code-base.

This is a graph of some changes made recently that were especially aimed at reducing the number of creatures that came out looking very wrong or swimming in unrealistic ways. I’m quite happy with how the results came out, with the number of creatures scoring 1/10 reduced by a factor of ten and the number of 10/10 creatures doubling.

The next major change to the game will address something a lot of people have asked about: why don’t creatures in the game exhibit the symmetry we see in nature. You can also follow development on Instagram now. Thanks for reading!

Categories: Tech


Leave a Reply

Avatar placeholder

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