Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
* * * * * 4 votes

Goopies - Evolving neural networks (w.i.p.)


  • Please log in to reply
135 replies to this topic

#13 nino

nino

    CC Resident

  • Validating
  • PipPipPipPip
  • 66 posts
  • Programming Language:C, C++, PHP, Python, JavaScript

Posted 03 November 2012 - 03:38 AM


Woah Chall, I must admit, your approach seems quite more elaborate and illustrious than mine! :biggrin:
It's almost like a mix between ordinary Neural Network functionality and what Tierra (http://en.wikipedia....ter_simulation)) does for artificial evolution. Your critters' DNA is actually composed of Instructions, thus, your critters acting more like independent Programs. I wonder, what type of Genetic Algorithm do you plan on using for your creatures to evolve towards better adapted models?

In my simulation I kept it more simple: all critters have a fixed Neural Network topology and the only thing that "evolves" is the connection weights between synapses. Thus, we can think of their virtual brains as (complex, polynomial) "functions" defined in their "genes". The GA just needs to worry about finding the most optimal function model to ensure the creature's survival. I wonder if, in your approach, you will consider some form of mutability inside the individual neurons (weights, biases, activation function, etc.) besides the main "topological" approach that you mention?

I'm excited to see what you come up to!


Alright, first input "gene" (red, left eye). Loads the memory neurons designated for the left eye's red:
{67, 6, 0, 68, 7, 0, 69, 8, 0, 70, 9, 0, 71, 10, 0, 72, 11, 0, 73, 12, 0, 74, 13, 0, 75, 14, 0, 76, 15, 0, 77, 16, 0};
The first digit specifies which input neuron and loads it into impulse's "stack", second digit specifies which memory neuron, and third specifies which operation (0 is store) and it stores the first value on the impulse's "stack", which would be the distance of the color that that neuron is seeing. The cycle then repeats, and will continue to do so until the gene runs out of indexes/operations.

If a gene needs access to a memory neuron, all it needs is the index of cell, and the operation 1, which loads onto impulse stack. So, if I wanted to access the distance of red at the first input neuron, it would look like this:
{..., 6, 1,...};

I also decided that since I'm more interested in the genes, and natural selection based on genes, I should focus less on the neurons, and more on gene optimization, so when a new organism is created, it will combine parent genes, and then modify/add existing/new ones. I know it's more like a very basic assembly language than genetics, but that's also pretty much what genetics are, instructions for the body. Same principal applies in my case too :) I'm ecstatic to see how my project turns out.

And I'm not using weights just because I can't get an exact definition of what the weight is supposed to do exactly. :S


The concept "connection weights" is only relevant when modelling artificial neural-networks on the classical sense, like this (http://en.wikipedia...._neural_network), which is what I did for my critters.

Your approach, nevertheless, seems to be fundamentally different to mine, particularly on the way you want your critters to respond to stimulus and perform input/output operations.

Your genetic algorithm (i.e. the way you will handle evolution, mutation and gene combination), on the other hand, can work virtually on the same matter than mine, if you'd wish, as long as you can represent an individual's "gene" as a single string of numbers (be it bits, integers or floats). On a typical Genetic Algorithm, after each generation, the best-performing critters are selected and their genes extracted (in my case neural connection weights (represented by floats), in your case instruction sets (represented by integers?)). Then, the genes are crossed over and mutated randomly in order to assemble a new generation of critters. Is more like "virtual breeding" that natural selection, but it gives fantastic results.
  • 0

#14 Upstream

Upstream

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 98 posts
  • Location:Netherlands
  • Programming Language:C, C++, PHP, (Visual) Basic, JavaScript, Perl, Bash, Others
  • Learning:Others

Posted 03 November 2012 - 04:59 PM

Nino you the man! I think this is the most refreshing and best post I ever read here! I am very impressed with your presentation and seemingly high quality of code! If this is your first project and it works as smooth as it appears then I see great things in the feature for you!

If you are going to distribute it I would like to participate. I don't know much about biology, neural networks and such but I like the idea and am enthusiastic and creative so you can never tell what ir will become. I have flurries of visions of the little goopies floating around in a big real life systems being useful in as well science as social networks.

So be sure to let me know when you have somethings new as I would like to see it!
  • 0
"The question of whether a computer can think is no more interesting than the question of whether a submarine can swim." (Edsger Dijkstra)

#15 nino

nino

    CC Resident

  • Validating
  • PipPipPipPip
  • 66 posts
  • Programming Language:C, C++, PHP, Python, JavaScript

Posted 04 November 2012 - 03:54 AM

Nino you the man! I think this is the most refreshing and best post I ever read here! I am very impressed with your presentation and seemingly high quality of code! If this is your first project and it works as smooth as it appears then I see great things in the feature for you!

If you are going to distribute it I would like to participate. I don't know much about biology, neural networks and such but I like the idea and am enthusiastic and creative so you can never tell what ir will become. I have flurries of visions of the little goopies floating around in a big real life systems being useful in as well science as social networks.

So be sure to let me know when you have somethings new as I would like to see it!


Haha, upstream! Thank you for your warm comment! :)
I am still working on a GUI that allows users to tweak parameters on the simulation (until now, all parameters had to be changed directly in the source code) and, given that there are many many parameters that can be adjusted (from the size of the world, to the type of neural network, to population size to even the colors of the entities) I'll need a few more days to get that running. I also want to implement a load/save system that allows users to pause and resume simulations (and all those things are first times to me!).

When I get all that done, Goopies 1.0 will be released for anyone to play with and I hope I get a lots of testers! :D
  • 0

#16 nino

nino

    CC Resident

  • Validating
  • PipPipPipPip
  • 66 posts
  • Programming Language:C, C++, PHP, Python, JavaScript

Posted 13 November 2012 - 08:47 AM

After a week full of work I finally had some time to invest on the project. I basically re-wrote the whole program from scratch and I'm glad I did. The code is MUCH more clean now, and I was able to get rid of most of the repeated functions by setting up a nice inheritance tree using C++ classes.

Although most of the changes may be invisible to the user, one of the greatest achievements was the creation of a Params class that encapsulates ALL of the tweakable parameters of the simulation. This will make the creation of the welcome screen (the window on which users will be able to set up parameters and -more importantly- load/save simulations) much more easy!

Another feature recently added was the Simple Recurrent Network (also called an Elman Network). Recurrent neural networks are much more similar to their biological counterparts (up to this moment I had only implemented Feed Forward networks). I hope that this new implementation will allow for the evolution of more intelligent critters on future simulations.

I've created a short video showing the critters with their new network style. Also, I've changed the colors (easily doable now that I have a Params class!). I will upload it on youtube tonight. For now, some screenshots:

Posted Image

Posted Image

Posted Image
  • 0

#17 Chall

Chall

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 349 posts
  • Location:Cedar Rapids, IA
  • Programming Language:Java
  • Learning:C, Java, C++, C#, Python, JavaScript, Assembly

Posted 13 November 2012 - 06:33 PM

After a week full of work I finally had some time to invest on the project. I basically re-wrote the whole program from scratch and I'm glad I did. The code is MUCH more clean now, and I was able to get rid of most of the repeated functions by setting up a nice inheritance tree using C++ classes.

Although most of the changes may be invisible to the user, one of the greatest achievements was the creation of a Params class that encapsulates ALL of the tweakable parameters of the simulation. This will make the creation of the welcome screen (the window on which users will be able to set up parameters and -more importantly- load/save simulations) much more easy!

Another feature recently added was the Simple Recurrent Network (also called an Elman Network). Recurrent neural networks are much more similar to their biological counterparts (up to this moment I had only implemented Feed Forward networks). I hope that this new implementation will allow for the evolution of more intelligent critters on future simulations.

I've created a short video showing the critters with their new network style. Also, I've changed the colors (easily doable now that I have a Params class!). I will upload it on youtube tonight. For now, some screenshots:

Posted Image

Posted Image

Posted Image


Might wanna change the color back to black. White is just too... bright. Black helps the eyes define the shapes they are seeing more easily, and I personally think black would look better than white in this case ;)
  • 0
Speaks fluent Java

#18 nino

nino

    CC Resident

  • Validating
  • PipPipPipPip
  • 66 posts
  • Programming Language:C, C++, PHP, Python, JavaScript

Posted 14 November 2012 - 03:12 AM

Might wanna change the color back to black. White is just too... bright. Black helps the eyes define the shapes they are seeing more easily, and I personally think black would look better than white in this case ;)


It's just a thing of taste, I believe! ;)
Although, more than for aesthetic purposes, the ability to change colors allows for a wider range of experimentation. Note that the Guppies actually "see" the same colors that you see. Therefore, an user could make, for example, all things black, forcing the critters to evolve and fine-tune their skin sensors to identify objects based on their size instead of their color?, or perhaps give the Guppies the ability to camouflage on their environment by shifting colors to match the background, who knows!

Creatures are now using Simple Recurrent Networks, or Elman networks. I've uploaded a new video to youtube. Most interesting moment certainly occurs at about 4:12, when one critter literally saves its neck after being trapped on a tight space! Some other nice behaviour I observed included Sweeping through bunches of food pellets, and (quite remarkable) bumping into other guppies on what seemed attempts to push them into the Zappers so they loose energy and die?? Are the critters already becoming effective hunters??



Hey, and Chall, how is it going with your experiment!? Any progress so far?
  • 0

#19 gregwarner

gregwarner

    Obi Wan of Programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1586 posts
  • Location:Arkansas
  • Programming Language:C, Java, C++, C#, PHP, Transact-SQL

Posted 14 November 2012 - 06:36 AM

Hmm, they only seem to be able to turn left. Clearly, these specimen have evolved to become NASCAR drivers.
  • 0

ti-99-sig.png
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#20 mbcev

mbcev

    CC Regular

  • Member
  • PipPipPip
  • 37 posts
  • Location:Scottsdale
  • Programming Language:C, Java, C#, Others
  • Learning:Others

Posted 14 November 2012 - 09:23 AM

Baaah, I'm so jealous! This type of stuff is like my life long dream. I just don't have time to work on my own project so I have to sit here salivating at your awesome Goopies!

Ultimately what I want to do (and I have bits and pieces of code written out from over the last 3-4 years honestly) is have a web interface which is basically just to serve as a rendering engine for what's happening in the artificial world. Then as far as the server-side technology. The environment is mostly coded in Java however the neural networks themselves, which I have designed to be "slot-able" are actually coded using Clojure. I'd like to then be able to just leave it running on a server and just check in on the guys through the web interface. Potentially even taking the idea bigger and working toward an end goal of a sort of massively-parallel computing project akin to the Folding@Home stuff.

But alas... no time >.>;;

Neat stuff though guys!
  • 0

#21 nino

nino

    CC Resident

  • Validating
  • PipPipPipPip
  • 66 posts
  • Programming Language:C, C++, PHP, Python, JavaScript

Posted 14 November 2012 - 10:00 AM

Hmm, they only seem to be able to turn left. Clearly, these specimen have evolved to become NASCAR drivers.


I noted that also.
My guess is that, given the properties of their circular world (which is full of circles of different sizes) one of the optimal survival mechanisms is actually to go around in circles. Although a bit dizzying (I will admit), their constant looping is clearly not random. Instead it's being constantly adjusted in order to avoid obstacles. Hmmm, perhaps in the future I could fill the world with irregular polygons and see what happens... :)

Note that this video was made just after a few hours of evolution, so the Neural Networks were still quite raw. Before I am able to perform longer simulations I'll need to implement a load/save system. Should be doing that this week. :)


Baaah, I'm so jealous! This type of stuff is like my life long dream. I just don't have time to work on my own project so I have to sit here salivating at your awesome Goopies!

Ultimately what I want to do (and I have bits and pieces of code written out from over the last 3-4 years honestly) is have a web interface which is basically just to serve as a rendering engine for what's happening in the artificial world. Then as far as the server-side technology. The environment is mostly coded in Java however the neural networks themselves, which I have designed to be "slot-able" are actually coded using Clojure. I'd like to then be able to just leave it running on a server and just check in on the guys through the web interface. Potentially even taking the idea bigger and working toward an end goal of a sort of massively-parallel computing project akin to the Folding@Home stuff.

But alas... no time >.>;;

Neat stuff though guys!


Mbcev, my idea in the long shot is actually the opposite to yours. :) I would like to be able to make the Guppies live paralelly on different clients. Perhaps each client could handle a different sub-population during each generation and then the server application would gather the fitness results and perform the selection/breeding algorithm, feeding back the new generation onto the clients. I don't know, however, if I'll be able to do this given my limited knowledge. I know that SFML has functions for creating client-server applications but I haven't dug into that just yet.

I would encourage you to give it a shot and code your experiment though! I would really enjoy seeing other attempts for virtual evolution. You could perhaps make use of some third party libraries for graphic rendering (there should be many for Java) so that you can focus on the Neural Networks themselves?
  • 0

#22 gregwarner

gregwarner

    Obi Wan of Programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1586 posts
  • Location:Arkansas
  • Programming Language:C, Java, C++, C#, PHP, Transact-SQL

Posted 14 November 2012 - 10:12 AM

I noted that also.
My guess is that, given the properties of their circular world (which is full of circles of different sizes) one of the optimal survival mechanisms is actually to go around in circles. Although a bit dizzying (I will admit), their constant looping is clearly not random. Instead it's being constantly adjusted in order to avoid obstacles.


Their outward-spiraling movement reminds me of a Roomba's pathing algorithm.

http://www.youtube.c...YHrq6To#t=0m30s
  • 0

ti-99-sig.png
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#23 nino

nino

    CC Resident

  • Validating
  • PipPipPipPip
  • 66 posts
  • Programming Language:C, C++, PHP, Python, JavaScript

Posted 14 November 2012 - 10:22 AM

Their outward-spiraling movement reminds me of a Roomba's pathing algorithm.

http://www.youtube.c...YHrq6To#t=0m30s



Hmm, never thought of that, but yes! Guppies behave much like robotic vacuum cleaners, lol.
  • 0

#24 gregwarner

gregwarner

    Obi Wan of Programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1586 posts
  • Location:Arkansas
  • Programming Language:C, Java, C++, C#, PHP, Transact-SQL

Posted 14 November 2012 - 10:27 AM

It's interesting to note that Roomba's are programmed to spiral clockwise, while your Guppies evolved to spiral counter-clockwise. Wonder if it makes a difference.

I know it goes against the natural evolution of the experiment, but can you manually edit their neural networks? For instance, take one Guppie and "flip" it so it spirals in the opposite direction? Then introduce one of the "flipped" ones to the pool and see if the trait catches on or is bred out after a few generations? This could be analogous to random "mutations" which sometimes get introduced into the gene pool.
  • 0

ti-99-sig.png
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download