Lil Critters – Class structure and the Nervous System

I’ve started working on the Lil Critters “Evolution Sim” project again. First thing to do was some refactoring, so I made many more classes and split up the methods. The classes and structure of the project is kind of interesting, since I am loosely modeling it after how the nervous system in living creatures tend to work. I’m no expert in biology, neurology or anything like that so I’m taking a more broad and general approach to the nervous system.

A critter’s “nervous system” is made up of three main classes which are Stimulus, Brain, Response. As you can probably guess, Stimulus is in charge of receiving input from the world outside of the critter and relaying those inputs to the Brain. The Brain chooses a response based on the input and sends this choice to Response. Lastly, Response allows the critter to perform some action as dictated by the Brain. There are other classes each critter has as well such as Raycast (to draw sight line) and Metabolism (to manage energy consumption). There will also be plenty more added as the project grows. The way I’ve been thinking of these classes in more specific terms is:
Raycast: Photons that hit the eye.

Stimulus: The eye that forms information from the photons that hit it and the neurons that transport that information to the brain.

Brain: Takes care of brain stuff… makes choices to call for particular responses based on input.

Response: The muscle system, applying forces to the critter when instructed to by the brain.

Metabolism: The chemical reactions and burning of energy in order to power the muscles and also just to maintain life.

It’s almost soothing to organize the series of inputs, analysis and outputs like this. This project often makes me think about real life a bit differently. While we all get the general idea that out bodies and minds are set up in this way, we typically don’t give this idea any weight or importance. I find it interesting to be building these little critters with this structure as a guide, which developed over billions of years of evolution.

Playing with Unity and My Critters

I’ve been away from the Nano project for a few months now and I’ve instead been spending my programming time learning Unity. It’s actually pretty easy to use, and after watching a few of the tutorials on Unity’s site I was good to go and started off on my new learning project, which I’ve been calling My Critters. This is an awful name and isn’t a name at all really, it’s just what I say when I tell my girlfriend what I spent my day doing.

Her: “Have you been playing video games all day?”

Me: “No! There were a few hours that I worked on my critters… AND I showered!”


Unity is a 3D engine typically used for making video games, incase anyone is reading this (no one is) and isn’t familiar with it. You can use Javascript and C# to write scripts for how the objects in your game should function.

Evolution Simulator Project

The Idea

In my case, I’m trying to make something I’ve been calling an evolution simulator. The idea is that when you start the simulation a few critters (aka spheres) and some food (cubes) are randomly dropped into a small flat world. The critters have the ability to detect the food via sight (raycasts) and then can move to the food (using physics and impulses) and eat the food. Now, every action the critters do burns energy, some actions burn more than others (moving forward burns more energy than turning) and simply existing slowly consumes energy, and when you run out of energy you die. In the end, critters try to get to food to stay alive, they will mate to make more critters and spread their genes.

Current State

This isn’t how it all works right now, currently I only have 1 critter who doesn’t burn energy at all and just poots his way around the world eating everything he sees, sweet life. But all that other stuff is coming and I don’t think it’ll be too difficult to get those basics in place. (In before the post where I talk about that stuff turning out to be really difficult.)

The Hard Part

The hard part comes when the critters aren’t told to do any of those things. The goal is to not have the instruction of move to food, eat food as an explicit instruction of the critters, instead the critters genes should determine what the critter does when it detects food, when it comes in contact with it, when it detects another critter, how it explores its environment, etc. This is when I’ll be getting into neural networks and stuff like that.


This whole idea is based off a project I saw years ago called Polyworld. The guy is a terrible presenter but it’s really inspiring the way the creatures in Polyworld develop their own survival strategies. My goal is to create a similar effect in a 3D space, the bigger goal is to then use this type of creature generation in a game of some sort.

Up Next

As of now, Nano’s development is on hold. I think Nano makes a decent portfolio piece and I’ve still got ideas for it that I want to implement, so the project isn’t canned, just on the back burner.

I’d really like to get some 3D models in the simulator. It’s really early, but I think having some models to look at instead of just geometric shapes would be more interesting to look at. Since I don’t know much about making 3D models, this part will likely require outside help. For me, the next part is to add more critters to the world, allow for mating, and add energy consumption.

Screen shots in next post!