Author Topic: OCULUS II  (Read 9328 times)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
OCULUS II
« Reply #15 on: May 02, 2008, 08:27:58 PM »
I think that was the plan, Eric's just never gotten around to it.

Offline bacillus

  • Bot Overlord
  • ****
  • Posts: 907
    • View Profile
OCULUS II
« Reply #16 on: May 10, 2008, 02:59:41 AM »
Wait...
about the increment thing, could you increment .tieloc until you hit .tieval, then increment that?
No, that's even more stupid. You'll likely lose 100 nrg for each 1 you gain. How about a one inc/one dec bot?
"They laughed at Columbus, they laughed at Fulton, they laughed at the Wright brothers. But they also laughed at Bozo the Clown."
- Carl Sagan

Offline gymsum

  • Bot Destroyer
  • ***
  • Posts: 215
    • View Profile
OCULUS II
« Reply #17 on: May 10, 2008, 11:30:52 PM »
cant you use (*a -1 mult sgn)? then add that number to it.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
OCULUS II
« Reply #18 on: May 11, 2008, 01:24:00 AM »
But if you're limited to just inc or dec, that doesn't really help.  I think it's impossible to create a bot that manages to feed itself (ie: not a veg) and reproduce with just a single inc or dec.  Using two (inc and dec) is probably too easy (not to mention severely limits the sorts of bots you could make).

So I still think a single store bot is the leanest bot possible that still allows a nearly full range of actions.

Offline Trafalgar

  • Bot Destroyer
  • ***
  • Posts: 122
    • View Profile
OCULUS II
« Reply #19 on: May 11, 2008, 11:44:23 AM »
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:
Code: [Select]
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:
Code: [Select]
+ 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).
Code: [Select]
*.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.
Code: [Select]
-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)
« Last Edit: May 11, 2008, 11:45:32 AM by Trafalgar »

Offline Peter

  • Bot God
  • *****
  • Posts: 1177
    • View Profile
OCULUS II
« Reply #20 on: May 11, 2008, 12:10:49 PM »
The loop could be a serious problem, I could imagine DB being held in a loop pretty easily.
Oh my god, who the hell cares.

Offline Trafalgar

  • Bot Destroyer
  • ***
  • Posts: 122
    • View Profile
OCULUS II
« Reply #21 on: May 11, 2008, 12:55:31 PM »
Quote from: Peter
The loop could be a serious problem, I could imagine DB being held in a loop pretty easily.

I'm not suggesting adding a loop operator. I included it and the [] in the first pseudocode to show the basis for the idea. As I said, you would unroll the loop (and convert the eye[num] into eye1, eye2, etc), and you can see what that looks like (with 2 eyes instead of all 9) in the third code block in that post.

Offline bacillus

  • Bot Overlord
  • ****
  • Posts: 907
    • View Profile
OCULUS II
« Reply #22 on: May 14, 2008, 02:27:40 AM »
Quote from: Trafalgar
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)
Ah, that's why I use the >= comparator (which I already was using, by the way). So if two eyes have conflicting data, they are chosen according to the priority list, Eye5 being the first choice:
Eye5
Eye6
Eye4
Eye7
Eye3
Eye8
Eye2
Eye9
Eye1
« Last Edit: May 14, 2008, 02:28:23 AM by bacillus »
"They laughed at Columbus, they laughed at Fulton, they laughed at the Wright brothers. But they also laughed at Bozo the Clown."
- Carl Sagan