genetic algorithms for webs

I had the first Skype session with Ollie Glass last night, where we discussed the first stages of exploring the use of genetic algorithms to evolve spiders’ webs. It was very useful, and I learned a lot.

The first reveleation was a different technique for checking to see whether a web had trapped a spider. I’d assumed that we would have to check each strand of each web for every fly, and suggested that we ran a first-pass check to see whether a fly was within the outer edges of a web, and only if it was would we then run a more detailed check against each strand.

Ollie, however, suggested a cunning alternative: check the colour of the pixel that a fly was on, and if it was web-coloured then it would be trapped. The downside is that this technique wouldn’t identify which web had trapped the fly, which would be important if we were going to rank webs according to how many flies they succeeded in catching. Or would it? Each web could be a very slightly different colour, so the colour of the pixel the fly was on would, in fact, identify the successful web!

We then had a fascinating discussion on whether the detection routine should be a method for the ‘fly’ class or the ‘spider’ class. In the end, we agreed that although it might be more realistic for the web to detect the presence of a fly, it was a neater programming solution for the fly to check, since we would only have to check one pixel per fly, rather than every pixel of ever web. The fly would then send a signal to the environment (in the shape of the overall programme), which would in turn signal other parts of the environment.

Discussion turned to how we might develop the webs. Ollie was keen to advance in small increments, though keeping a note of ideas for fture stages, which makes sense, and is well suited to the approach of object oriented programming.

Immediately after the session I tried to write the code for checking the colour of pixels. We’d run a small sketch during the session to test it, and the principle worked fine, but my first attempt for the web simulation slowed the code to a crawl. I’ll try again, reducing the number of flies, and see if I can code it more efficiently.

Tags: , ,

Tuesday, July 13th, 2010 coding

Leave a Reply