Join us on Discord!
You can help CodeWalrus stay online by donating here.

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.

semiprocoder

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
  • Calculators owned: ti nspire, ti 84 plus se
My cemetech username is awesommee333.

Dream of 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.
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Powered by EzPortal