Making a worm intelligent

I know you guys are busy with the project running here, but I ask it anyway. It has propably been done before, and it is propably not that hard or cool, but I’ve made this worm:

http://www.lbr-designs.be/wormintel.swf

And for the moment, the only thing it does is watch a smaller worm. What I want now is to make a script to make the big worm learn itself how to catch the worm.

It must be possible, any ideas? Or have you seen this before, I know the footer of somebody here was something like that, but that’s too easy, I want it to be more advanced…

Are you up for it?