PDA

View Full Version : WILL's AIUnit.pas (NNs using GAs to learn)



WILL
23-05-2007, 05:57 AM
Hey all. I was wondering if anyone out there knew much about using GAs with NNs?

I had made this unit quite some time ago to assist in the use of training a bunch of NNs with the use of a GA ran through various generations of trials in which they would learn to adapt to the inputs given and respond in a way that benefits them (ie a health score).

I've derived the classes in this unit from a minesweeper tutorial (http://www.ai-junkie.com/ann/evolved/nnt1.html) by Mat Buckland on GAs and NNs at ai-junkie.com. If anyone can take a look over it and see if there is anything that I may have gotten wrong, I'd be grateful.

My re-implementation of his mine-sweepers program in Pascal was so far unsuccessful as my little bugs don't seem to be learning anything.

I'll post the 'Bug World' code later. I just want to see if I made any errors in this unit that might be causing it. Actaully you can grab the code at an old site that I put up a few years ago: http://aiworkshop.tripod.com/ Full source is there too. (used Delphi 5 and DelphiX components)

Perhaps if someone were to try and use it themselves for testing?

Oh and for the record the code submitted by Chris Reitzel on the tutorial does NOT work (it seems that noone cared to check his work for results before adding it :roll: typical)

Digital Mode seems to work better then Analog as I've actually seen some results in a another simulation I've done than the minesweeper clone attempt.

Oh and please bare with some of my code, it's a bit dated and I'd likely have done a few things differently these days.


EDIT: Darn! the [pascal] tags are screwing up the code you'll just have to get it from my old site then. The source is there in with the bug world code.

jdarling
23-05-2007, 01:45 PM
Yep, played with GA and NN's quite a bit. The biggest trick is getting the mutation code correct. I wrote an article about the topic for Delphi Mag a while back, unfortunately it never got posted as it was to long. I'll have to look around and see if I can find a copy.

BTW: A good thing to look at is storing the weighting method as a pointer and choosing random starting weighters. Then you can use that as part of your mutation in a 1 of n scale. Its very interesting how the results change and the curve modifies when you use this method.

WILL
23-05-2007, 08:36 PM
Ok cool. Well if you have time to do a quick look over my Bug World code that'd be great.

It's been a few years since I've touched it, but I'd really like to resolve this issue that stops the NNs from training properly.

technomage
23-05-2007, 08:38 PM
I did AI at University, so I know ab it about it. I'll have a look if I get time.

WILL
23-05-2007, 09:21 PM
That'd be great Dean. I'd appreciate it. :)

tanffn
27-05-2007, 06:55 AM
Hi WILL, my ants are based on the same NN/GA code from ai-junkie. It works quite well and its been slightly improved from the original version.

Feel free to download it, you’ll have the code there.

WILL
27-05-2007, 07:39 AM
Oh ok... uh, where exactly is this? :scratch:

EDIT: Oh wow, I completely forgot about your Ants program (http://www.pascalgamedevelopment.com/viewtopic.php?t=3284). :P How silly do I feel. :lol:

Anyhow, I don't see the source code anywhere in the thread or on the page. Did you release it?

Also, besides the simulation it's self are you doing anything different in the way that you 'teach' the NNs using Fupster's method? I tried to follow it to the 'T', or as close to it as possible.

If you can feel free to look over and dissect my code for the Ant World program.