July 10, 2020, 12:34:38 am

The shoutbox is currently out of service. Join us on Discord instead.
You can help CodeWalrus stay online by donating here.

WARNING: DO NOT UPGRADE your TI-83 Premium CE or TI-84 Plus CE to OS 5.5.1 and higher. It removes all compatibility with most games and removes ASM/C programming! DOWNGRADING IS IMPOSSIBLE. BE WARNED! Likewise, do NOT update your TI-Nspire CX past OS 4.5.0, else using Ndless and ASM/C programs will be impossible.

Neural Network Evolution Simulator in Processing in Eclipse

Started by semiprocoder, November 15, 2016, 12:11:02 am

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


November 15, 2016, 12:11:02 am Last Edit: November 15, 2016, 12:27:43 am by DJ Omnimaga
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 with processing and has multiple files(Note that x, y, and z are stored in an array called fitnessSettings in the class Creature):
https://www.dropbox.com/s/b3fl8mvdetp724b/Neural Network.zip?dl=0
My cemetech username is awesommee333.

DJ Omnimaga

I didn't have time to try this yet Semiprocoder and I can't really understand much until I try it myself, but I fixed your download link because the space in it broke it.

Powered by EzPortal