I’ve been working on my genetic simulation project for the past few weeks and have a few updates on the project I want to discuss:
First up is the new look! I’ve spent some time generating creature bodies. For this I chose a point and did a 180 degree sweep plotting points at a various distance (using Perlin Noise) and then mirrored the resulting shape. This generates a fairly primitive body type, which while unique does look quite alike to the other creatures. This enables you to be able to see which direction each creature is facing more easily. In addition to this I’ve added a background texture to make the whole thing look a bit nicer!
Secondly I’ve modified the energy function: the creatures now expend energy proportional to their speed and size. The equation is: energy = velocity^2 * size^3 + c, where c is a tunable parameter. Off the back of this, eating food no longer refills the energy level back to 100% – it now refills a quarter per piece of food eaten. This helps to weed out the creatures which aren’t as good at locating food. Additionally I’ve added a few more inputs to the creature’s neural network. It is able to see information about the closest predator, include it’s position + colour. This hopefully will allow them to avoid predators, however I haven’t observed this in any of the simulations.
I’m going to create the new project in C++ and make use of OpenGL for the rendering side of the project. My reasoning for using C++ is threefold:
- By using a language like C++ compared to JavaScipt, I’m able to avoid a lot of unnecessary overhead, which will allow me to run larger and more complex simulations.
- I gain the ability to work directly with the GPU. Running graphics and neural networks on the GPU allows for more to be done on the CPU. (yeah I could use WebGL, but…)
- I always enjoy developing in C++. It’s a more challenging language than JS (duh), and adds more focus on writing efficient code. I’m a sucker for trying to write the most optimised code, and in a project like this, optimisation is always good!
I’m basing this project off of the project I did for my dissertation at University titled ‘Procedural Generation of Terrain and Biome Environments’. In a nutshell it generated ‘random’ 3D terrain landscapes and applies temperature + humidity gradients to simulate forest, desert, jungle, etc environments. The program was written in C++ and used OpenGL, so there’s a good section of the rendering engine which I can make use of. Sadly a bunch of it needs removing because this project is 2D only, so some stuff will need rewriting and changing. I’d love to turn this into a 3D project, but I think procedurally generating 3D creatures and applying evolution is an entire project on its own. (if you’re also interested in how that could work, I’d recommend reading this paper.
The code for the JS project is available on GitHub here. The C++ code will be up soon too, and it will be written much better than the JS!
I’m a software developer and recent graduate from the University of Hull. I’m fascinated by machine learning, artificial intelligence & procedural generation, and love sinking into exciting projects such as games, simulations & websites!