I was thinking that the many many many SGized comparisons are a bit inefficient in CPU-usage, and thought about alternatives. What I came up with first:

`highest = -4`

highestVal = 0

for (num=1; num<9; num++):

if (eye[num]>highestVal):

highest = num - 5

highestVal = eye[num]

focuseye = highest

The first step to implementing that would be unrolling the loop, of course. Next I thought, well, to avoid doing a bunch of stores, we could make highest and highestVal be stack values that we change instead of actual variables. Unfortunately, that is, as far as I can tell, impossible. Actually, I can make them stack variables and do work on them just fine. The problem is that they aren't affected by the boolean stack's top value. They run whether it's true or false.

If highestVal were the topmost stack value and highest was below it, what I had for popping/dropping highestVal and changing highest was:

`+ dup ^ -4 + *.eye1`

, with -4 and *.eye1 replaced by other values for other eyes.

I did write a version which uses stores, but it can have up to 19 stores in a cycle if the eyes are all perfectly in order so that eye2 is higher than eye1, eye3 higher than eye2, etc (DNA length 93). Here's a snippet of it with the beginning, two eyes, and the end (Actually, there is no end).

`*.eyef .highestVal store`

*.highestVal *.eye1 <=

-4 .focuseye store

*.eye1 .highestVal store

dropbool *.highestVal *.eye2 <=

-3 .focuseye store

*.eye2 .highestVal store

dropbool

There's one optimization in that - it starts highestVal off with the value in eyef (maybe I could actually modify eyef instead), so that no stores will be made for eyes which see nothing closer than eyef. Effectively, if the focuseye is the best one there will only be one store. If we use eyef instead of highestVal, it would be 0 stores.

OCULUS II's DNA length is 524, but of course it has the huge advantage of *always* only having one store.

Alternately, I've made something else that you might consider an improvement on OCULUS II (Although I wrote this with pybot, and the code came out very similar to OCULUS II, and then I rearranged the eye order so that it came out in the same order too, for ease of comparison). Most of the DNA came out the same, but this has most of the multiplication replaced by &, which should be faster, and it checks to make sure it isn't setting focuseye to what it is already set to. Comparisons with a lower eye to a higher eye use >= instead of >, which makes the DNA a tiny bit larger, but that means eye1 is considered more important than eye2-9, eye2 is more important than 3-9, etc. Oh, and apparently we omitted a condition set for a different eye. You omitted #6, whereas I omitted #5. This has a DNA length of 537.

`-4 *.eye1 *.eye9 sub 1 add sgn 0 floor *.eye1 *.eye8 sub 1 add sgn 0 floor & *.eye1 *.eye7 sub 1 add sgn 0 floor & *.eye1 *.eye6 sub 1 add sgn 0 floor & *.eye1 *.eye5 sub 1 add sgn 0 floor & *.eye1 *.eye4 sub 1 add sgn 0 floor & *.eye1 *.eye3 sub 1 add sgn 0 floor & *.eye1 *.eye2 sub 1 add sgn 0 floor & mult 4 *.eye9 *.eye8 sub sgn 0 floor *.eye9 *.eye7 sub sgn 0 floor & *.eye9 *.eye6 sub sgn 0 floor & *.eye9 *.eye5 sub sgn 0 floor & *.eye9 *.eye4 sub sgn 0 floor & *.eye9 *.eye3 sub sgn 0 floor & *.eye9 *.eye2 sub sgn 0 floor & *.eye9 *.eye1 sub sgn 0 floor & mult add -3 *.eye2 *.eye9 sub 1 add sgn 0 floor *.eye2 *.eye8 sub 1 add sgn 0 floor & *.eye2 *.eye7 sub 1 add sgn 0 floor & *.eye2 *.eye6 sub 1 add sgn 0 floor & *.eye2 *.eye5 sub 1 add sgn 0 floor & *.eye2 *.eye4 sub 1 add sgn 0 floor & *.eye2 *.eye3 sub 1 add sgn 0 floor & *.eye2 *.eye1 sub sgn 0 floor & mult add 3 *.eye8 *.eye9 sub 1 add sgn 0 floor *.eye8 *.eye7 sub sgn 0 floor & *.eye8 *.eye6 sub sgn 0 floor & *.eye8 *.eye5 sub sgn 0 floor & *.eye8 *.eye4 sub sgn 0 floor & *.eye8 *.eye3 sub sgn 0 floor & *.eye8 *.eye2 sub sgn 0 floor & *.eye8 *.eye1 sub sgn 0 floor & mult add -2 *.eye3 *.eye9 sub 1 add sgn 0 floor *.eye3 *.eye8 sub 1 add sgn 0 floor & *.eye3 *.eye7 sub 1 add sgn 0 floor & *.eye3 *.eye6 sub 1 add sgn 0 floor & *.eye3 *.eye5 sub 1 add sgn 0 floor & *.eye3 *.eye4 sub 1 add sgn 0 floor & *.eye3 *.eye2 sub sgn 0 floor & *.eye3 *.eye1 sub sgn 0 floor & mult add 2 *.eye7 *.eye9 sub 1 add sgn 0 floor *.eye7 *.eye8 sub 1 add sgn 0 floor & *.eye7 *.eye6 sub sgn 0 floor & *.eye7 *.eye5 sub sgn 0 floor & *.eye7 *.eye4 sub sgn 0 floor & *.eye7 *.eye3 sub sgn 0 floor & *.eye7 *.eye2 sub sgn 0 floor & *.eye7 *.eye1 sub sgn 0 floor & mult add -1 *.eye4 *.eye9 sub 1 add sgn 0 floor *.eye4 *.eye8 sub 1 add sgn 0 floor & *.eye4 *.eye7 sub 1 add sgn 0 floor & *.eye4 *.eye6 sub 1 add sgn 0 floor & *.eye4 *.eye5 sub 1 add sgn 0 floor & *.eye4 *.eye3 sub sgn 0 floor & *.eye4 *.eye2 sub sgn 0 floor & *.eye4 *.eye1 sub sgn 0 floor & mult add 1 *.eye6 *.eye9 sub 1 add sgn 0 floor *.eye6 *.eye8 sub 1 add sgn 0 floor & *.eye6 *.eye7 sub 1 add sgn 0 floor & *.eye6 *.eye5 sub sgn 0 floor & *.eye6 *.eye4 sub sgn 0 floor & *.eye6 *.eye3 sub sgn 0 floor & *.eye6 *.eye2 sub sgn 0 floor & *.eye6 *.eye1 sub sgn 0 floor & mult add dup *.focuseye != .focuseye store dropbool`

So what happens with yours if there are targets in two eyes with exactly the same distance? (The >=s in this one should prevent that from resulting in more than one eye's addition occurring)