Author Topic: Neurbugs, neural network bugs  (Read 437 times)

0 Members and 1 Guest are viewing this topic.

Offline cur8xgoTopic starter

  • Regular Contributor
  • *
  • Posts: 148
  • Country: us
Neurbugs, neural network bugs
« on: June 22, 2019, 12:33:44 am »
If this is in the wrong place please just delete thanks sorry

This is my totally for fun, totally un-researched, un-homeworked, off the cuff neural network life simulator

Think of a playing field, like a football field.

Randomly disperse "bugs" on it

Randomly disperse food on it

Each bug can see whatever the next object in its line of sight (also its movement heading) is. That object could be a wall or a piece of food.

Each bug has two input neurons connected to its eye, one for "food" one for "wall"

Each bug has two output neurons, one for "heading rate of change" (heading is for movement and seeing), the other is for velocity

The neuron weights are randomized.

Let the games begin!

Each "frame" of the game is like an RPG. All the bugs get to "see", update their input neurons, update their output neurons, and then "move". Then the frame is done.

On the next frame, things like bug energy are deducted or added (if they stepped on food). Bugs with zero energy die.

Once all the bugs are dead or all the food is gone, that "game" is over. A new one is started with the same bugs, but new random locations for food and bugs.

This repeats until an "epoch" is reached (just a number of games).

Then all the bugs are evaluated according to how much they ate and where they rank compared to the other bugs. Loser bugs have their neurons erased and randomized. Good bugs "mate" with the top-scoring bug.

Then the next epoch starts and it repeats.

Note you can add the option of randomly sprinkling "wall" or even placing a long section of fixed wall to make their task harder.

I've gotten them to evolve pretty quickly to be able to eat more than 95% of the food. Its interesting to watch the stats as the percentage eaten goes up, the amount travelled goes down, etc..

Anyways it would also be cool to plot the statistics over time and see what sort of oscillations occur. You can get drastically different evolutions each time you run it since it seeds the first neurons randomly. "Gradient descent" I guess.

This compiles in codeblocks on Windows XP. Also included is a compiled exe (its a console app).

FYI: the "spectating" threshold is what ratio of food eaten/food available must be reached in order to allow manual viewing of the playing field so you can watch your bugs do their thing..this allows much faster evolving

Note that if things dont seem to be evolving fast, just stop and restart with a new random seed. On one run it was stuck at 0.43 ratio. I stopped and restarted it and got to 0.95 ratio in 400 games (about 5 seconds)

I'm looking for any advice on how to make this better. Its a fun toy and could easily be modified. I think it has some "bugs" though..(pun intended). I tried adding a feature where the bugs could shoot each other but there started to be strange things like bugs randomly teleporting. But that feature is disabled now ( code is still there but commented out)..otherwise it seems to work okay.


« Last Edit: June 22, 2019, 12:39:09 am by cur8xgo »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf