[AI]: Neural Network and Genetic Algorithm test

Hi,

My name is Jean-Francois Gallant , aka Pyroevil. After getting some fun to code Molecular , I starting to playing with Neural Network and Genetic Algorithm. It’s my brother , a game developper , it’s give me this idea. I reading a lot about this and start some experiment. Coded and compiled with Cython in a fast C python extension. Here I want to share my progress and hope you have fun to watch little creature evolve by itself like me:

My website:
http://pyroevil.com/category/scripts-addons/neural-network/

Python module with samples blend file download page:

Most recent video biped learn to walk:

Quadruped learn to walk:

Quadruped learn to walk:

Cart learn to balance a pole:

Pac-Man vs Ghost:

Tank try to catch points:

I will try to update this post with new stuff soon.

1 Like

Very cool

I’m curious, how are you deciding which traits propagate (Move on to next generation)
For example, maybe the traits of whichever creature walks farthest gets added to next generation.
I expect that evolution is the future of effective AI, for some game genres at least.

Anyways, keep it up, I like it :yes:

Not sure I understand you question but the way it’s work for the quatruped video:

  • More a creature go far , more points it’s get
  • 4 ( or the numbers you want ) best creatures is keep for the next generation without modification (call elite members)
  • all others creatures of the next generation is made by crossover: Parent of the previous generation are randomly choose with “roulette wheel” game. More creatures have points , more you get chance to be choose and make childs togethers.
  • small amount childs of the next generation have chance of mutation: some chromosome is randomly regenerated.

With all this , if you give the rights inputs to your network, good crossover rate, good mutation rate and choose the good way to award them , it’s evolve and converge toward the solution you want.

I currently working on a biped sims too :slight_smile: Videos coming when I get nice result of it.

I had some amazing hunting behavior using vision cones,

Peripheral vision =torque body that way
Central vision =drive locomotion
But allowing your algorythms to use sensor inputs may yield suprising resaults.

Also you may want to add “feelers” and prey.

For some seed rules, that can be adapted on, for biped motion, check out the torqueRig,

For some seed rules, that can be adapted on, for biped motion, check out the torqueRig,http://www.blenderartists.org/forum/showthread.php?295093-TorqueRig-Walking-rag-doll-physics

yes I see you rig , really nice work ! I already have a “simple rig” for my biped … the same than my quadruped but by removing 2 legs :stuck_out_tongue: But I take I look on you system when I have time for sure.

Wow, that’s pretty fascinating :smiley: Hmmm… In the tank video there is a plateau effect at generation 250 - why?

Oh! This is awesome. Well done.

I have never got involved with genetic algorithms but I am very interested to learn. Any ideas where to start?

Also another, how do you use the compiled Cython program? Can it be loaded as a typical Python module?

Yes , cython make more easy to create compilated python module and it’s loaded has any other module you use with python. For genetic algorithm and neural network , my best website is http://www.ai-junkie.com/ A old but good website to learn the basic. Most of my code is base on this turorial.

In the tank video there is a plateau effect at generation 250 - why?

Because it’s reach the maximum of what they can do with it’s capacity. When you are learn a skill and you master it and most of time you make no errors , you reach a plateau. After 250 generation all tank master it’s skill to catch points and be equal.

That’s really amazing! I’ve been studying genetic algorithms lately. And they’re just too complicated! for me, creating a simulation like this was like, the furthest thing I can think of. Really great job!

Very cool stuff Jean-Francois! It reminds me of this guy http://www.strandbeest.com/
He did a similar thing making creatures that could walk (on the computer) and letting them evolve based on their performance. Now he’s creating them in real life :slight_smile:

Hi Richard!

Thanks for the links , I will going to check that for deeply when I have time ! Really interesting.

I add a download page to my website for this: http://pyroevil.com/bge-neuralnetwork-and-genetic-algorithm-v0-01-download/

Just to mention no support/docs is provided. But a samples blend files is available.

The library is really useful for me! I’ve already begane to understand it from the samples you’ve provided. Really appreciate your work!

Edit: after leaving the pacman test overnight now the pacmans tend to move in “groups”, this is amazing :stuck_out_tongue:

Really impressive. I take time to take a closer look on the thing. I think he don’t use neural network , only genetic algorythm to find the best configuration of it’s mechanics for it’s strandbeest. Really impressive. NASA use genetic algorythm to find the best configuration for a antenna to catch radiowaves if I remember ( see this on wikipedia I think ).

The library is really useful for me! I’ve already begane to understand it from the samples you’ve provided. Really appreciate your work!

Edit: after leaving the pacman test overnight now the pacmans tend to move in “groups”, this is amazing :stuck_out_tongue:

Happy to hear that ! If you are be able to do somethings new with it , it’s will be appreciated to shared some video with us :slight_smile:
I currently working on a bipped version. I make my network " recurrent" , I put “ouputs” in variables that I put back in “inputs” at the next iterations. It’s a kind of short-term memory. I get really better result with biped … but not with quadruped strangely. I not test it on others samples files I give on my website.

Hi !

Long time without posting or making new video … sorry , too busy.
It upload a new video with a biped. This biped learn with a new type of neural network I did without modify the compiled code but only the python BGE code. I put the current tic (frame) outputs in the next tic (frame) intputs. This give a Jordan recurrent network type. That’s simulate a kind of short-term memory.

They need two arms, or a tail for balence

Have the algorythmic input also create rules for moving the balance arm or tail… :smiley:

Amazing work,

I try to reproduce this experiment , not sure they need arm or tail:

What did you mean by algorithmic rules ?

The genetic algorythm, does it apply forces?

If so what “seeds” does it use?
9.8*own.mass is a good random rule piece,

I am talking about randomly populating a motion actuator in each limb.