Thursday, 4 February 2010

Developer Journal 3

The last time I was working on the simulation, I set the number of internal neuron groups to one and the number of internal neurons to sixteen.

The reason I was doing this was to see whether the population was dying out because some agents had too few internal neurons and because other agents had too many.

When I did this, the program complained that there were more neurons than the program expected. I spent a long while tracking down the error and found out the cause. The previous programmer had written the code in a non-dynamic way with a few assumptions. The code assumed that every input and output neuron group would have only one neuron.

That was a fair enough assumption. However, my neural network has input and output communication neuron groups. These groups have eight neurons each. This was what caused the miscount.

I was lucky that the previous programmer had written code to check the number of neurons. I would prefer that the neural network code be completely dynamic.

Moving on.

Before I worked on specifying the number of internal neurons, I was working on improving the performance of the simulation. I changed the rendering code from non-immediate mode to immediate mode. I also modified the code to use a viewing frustum. There are more things I can do with immediate mode but the performance I've got at the moment is good enough. I need to do some more profiling to decide what to optimise.

I suspect that I can optimise the pixel reading code, the communication code and the neural network activation and update code.

Before I do more optimising, I've decided to work on getting the population to be stable.
  • Remove agent death from old age
  • Remove agent ability to hit
  • Reduce energy drain and energy action costs
  • Reduce energy usage for a period after mating as a reward for mating
  • Reduce the number of agent body colours
  • Modify agent vision from smudge vision to splat vision
  • Increase the number of pixels for vision
  • Reduce the size of the world
  • Stagger the introduction of agents


  1. Binh,
    It seems we have very similar research goals! Mind if I get your email? I'm interested in the optimization work you've done with polyworld; would you be willing to share a patch? My research is just getting started and I, too, will be modifying input and output neuron groups to fit my needs. Do you have any more notes on performance? :)

    frikker @

  2. Hi Blaine,

    My email is tb_nguyen at hotmail dot com. I'd be happy to talk further with you.

    Yep, I can share the modifications to polyworld with you. Please note that the code is a little rough at the moment. Email me and I'll send you a copy.

    I do intend to make a web page soon to make all this stuff more accessible soon.

    In regards to performance, the current bottlenecks include communication and neural networks. This is nice because the changes in graphics to immediate mode with a view frustum has been enough for practical purposes.

    Communication is a bottleneck because I don't have a spatial data structure to reduce the number of checks to determine what agents are near other agents. I intend to implement a simple spatial data structure soon, something like an quad-tree or an oct-tree.

    Neural networks are a bottleneck because there are so many neural networks and because each neural network has so many synapses. I'm not sure what to do here other than to keep the number of agents to about 300. A more advanced approach would be to create a client server model with each client taking on about 100 agents.

  3. Oops, I just noticed your email in your post. I'll send you a copy of my work a little later today after I've made a few changes to make the program a little easier to use.