Neural Network Evolution Simulator

So I recently watched carkh's videos on his evolution simulator, and they really interested me. Thus I have started making an evolution simulator of my own based on neural networks.

I have it partially completed, and I decided to have it simulate the prisoner's dilemma. If you don't know, the prisoner's dilemma goes like this: There are two parterns in crime, but they don't really know each other, and they individually told: "If you both don't confess about each other, you will both go to jail for x years." "If you confess and your partner does not, then you will be set free and your partner will go to jail for y years, and vice versa." "If you both confess, then you will both go to jail for z years."

Generally, x,y,z>0 and y>z>x, but I programmed it so that you are free to play around with the parameters.

So how the evolution part of this simulator works is that there are some amount of creatures(I am currently keeping it at 200 to prevent lag), and, at each step of the simulation, every creature is paired up with one other creature.

These two creatures then battle off in the prisoners dillema. Each creature outputs any number between 0 and 1. If that number is <0.5, then that means the creature confessed, and if it is >=0.5, then that means the creature didn't. After they each go once, they are each fed the ouput from their opponent's previous run(and the rounded outputs). Each pair of creatures plays ten games. At each game, each creature gets a sentence corresponding with the above rules.

Each creature also has two numbers: their total sentence and the number of times they played. The "fitness" of each creature is total sentence/number of times played. The creatures are then sorted by fitness, and the half of the creatures with the highest fitness is killed. The other half is reproduced and modified slightly, with the total sentence equaling the fitness of the parent and the number of times played equaling 1 to not give new creatures too much of a luck advantage.

So, since the normal prisoner's dillema would be boring, as each creature is obviously going to evolve to always confess, I decided to set x(or the sentence for both creatures confessing)<=0.0 to spice things up a bit.

Here is a picture(I can give more explanations, but the main thing is that the bottom graph represents the best fitness of any creature at any moment. The creatures generally tend to all confess or all not confess). In this case, x=-0.01, y=10.0, and z=3.5:

Anyways, my code was written in eclipse and has multiple files(Note that x, y, and z are stored in an array called fitnessSettings in the class Creature):

Sign In or Register to comment.