That looks very complicated...
One thing I noticed is you only shoot when eye5 is over 50... but if you're seing an enemy he may be headed towards you (Or you towards him) so you may aswell start shooting the second you see him.
This is the code for Body (The next tutorial bot after Beholder)
(I added some comments to make everything as clear as possible)
[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']
'Always move fast forward
'I may be simple and stupid, but if I move fast the others won't have time to think.
start
30 .up store
stop
'Always shoot if I can see anything in eye5
'I even shoot my own offspring, this is in no way an advantage
cond
*.eye5 0 >
start
-1 .shoot store
stop
'Reproduce if I can't see anything in eye5 and I have enough body and energy for it.
cond
*.eye5 0 =
*.nrg 5000 >
*.body 1000 >
start
50 .repro store
stop
'If energy exceeds 3000 and I'm smaller than 1500 body, spend 100 energy on body (Producing 10 body I think)
cond
*.nrg 3000 >
*.body 1500 <
start
100 .strbody store
stop
'If energy is running low but I'm bigger than 200 body, then eat some 10 body gaining 100 nrg (I think)
cond
*.nrg 500 <
*.body 200 >
start
100 .fdbody store
stop
It's only 5 very small and simple genes. The point is to show how important the actions of these genes are.
It doesn't even boost its shots, or try to aim... it even shoots it's own kind...
So how does it beat Beholder ?
- It keeps a konstant speed of 30 which is too fast for Beholder to keep up. (This is not always an advantage, but usualy if you can set the pace for the fight you'll have the advantage.)
- It keeps balanced body and energy levels, 500-3000 energy and 200-1500 body (Aiming for 3000 energy and 1500 body ofcourse)
- It produces big strong offspring making sure they end up with atleast 2500 energy and 500 body and generaly 1500 is a fairly large body size. Bigger body = Stronger shots
(In the F3 league size makes a big difference since there's no shell, poison, venom or such.)
So my sugestion for a shot gene would be something like this :
(On a side not, I usualy just cram the fight movements into the shot gene, but I suspect you're handeling this elsewhere.)
I also haven't taken poison and shell into account since it's an F3 bot and it won't be usefull untill it's able to compete in F2.
[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']cond
*.eye5 0 >
*.refeye *.myeye != and
*.IFFF *.foe = and
start
*.refypos *.refxpos angle .setaim store
*.refnrg *.body 2 mult <
-1 .shoot store
not
-6 .shoot store
'Boost shots if close to oponent
*.eye5 50 >
28 .shootval store
not
0 .shootval store
stop
But from what you've mentioned it sound like regulating body is your biggest issue, so I think you'll gain even more by looking at the genes in Body (The bot )
And one last thing I'd like to mention, I think you're overcomplicating it. Behavior is not always good, it'll often get in the way of what you realy wan't to accomplish.
So making a good but is as much about removing harmfull code as it is about adding code. So it's a good idea to test every new behavior right away, and generaly you can never assume what you did will make things better, you should probably assume the oposite and check that it is in fact an improvement.
You can often improve a bot by cutting things away.
You can even get an idea about harmfull behavior by throwing the bot in a sim and letting it mutate... if you're very lucky you may even be able to start a big sim full of SF2's with mutations enabled, let them mutate a litle and then try to throw in a single Beholder. Anyway my point is that mutations may break certain genes, and sometimes the bot will become a lot stronger without that gene, revealing which genes where preventing the bot from winning.
Ofcourse it's not likely that one of the mutated bots will be able to beat Beholder, but it can happen, and if nothing else you can still just run an evo sim with SF2 alone and see what genes evolution decides to break.
So, to sum it up, appart from working on the shoot gene, I think you'll get a lot out of regulating body trying to stay big, and from cutting away genes and code that are getting in the way or slowing the bot down.