Author Topic: OCULUS  (Read 1653 times)

Offline bacillus

  • Bot Overlord
  • ****
  • Posts: 907
    • View Profile
OCULUS
« on: April 26, 2008, 03:04:47 AM »
The OCULUS code snippet has quickly become a standard amongst my bots, mainly because of their amazing efficiency of using all eyes, and virtually no drawback apart from its size:

[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']-4 *.eye1 sgn mult *.eye2 sgn -- abs mult *.eye3 sgn -- abs mult  *.eye4 sgn -- abs mult *.eye5 sgn  -- abs mult
*.eye6 sgn -- abs mult  *.eye7 sgn -- abs mult *.eye8 sgn -- abs mult *.eye9 sgn -- abs  mult  4 *.eye9 sgn mult *.eye2 sgn
 -- abs mult *.eye3 sgn -- abs mult   *.eye4 sgn -- abs mult *.eye5  sgn -- abs mult *.eye6 sgn -- abs mult  *.eye7 sgn --
abs mult *.eye8 sgn -- abs mult add -3 *.eye2  sgn mult  *.eye3 sgn -- abs mult *.eye4 sgn -- abs mult *.eye5 sgn -- abs
mult   *.eye6 sgn -- abs   mult *.eye7 sgn -- abs mult *.eye8 sgn -- abs   mult add 3 *.eye8 sgn mult *.eye3 sgn -- abs mult
  *.eye4  sgn --   abs mult *.eye5 sgn -- abs mult *.eye6 sgn -- abs mult *.eye7 sgn --   abs mult add -2  *.eye3 sgn mult
*.eye4 sgn -- abs mult *.eye5 sgn --  abs mult *.eye6 sgn -- abs mult *.eye7 sgn --  abs mult add 2 *.eye7   sgn mult
*.eye4 sgn -- abs mult *.eye5 sgn -- abs mult *.eye6 sgn --   abs mult add -1  *.eye4 sgn mult *.eye5 sgn -- abs mult
*.eye6 sgn --  abs mult add 1 *.eye6 sgn mult *.eye5   sgn --  abs mult add 0 *.eye5  sgn mult add .focuseye
store

this sets the focus eye; then you can decide whether it's worth turning towards because you can read a bot's vars even behind you. OCULUS is most efficient when broadening a bot's eyesight. To turn towards non-conspecs, add this code:


cond
'conspec code here
*.eyef 0 !=
start
 *.refxpos *.refypos angle .setaim store
stop


This is only a beta version that settles conflicts depending on whatever takes the least to turn towards; I'm trying to code a version that turns towards the closest thing relative to the bot.
« Last Edit: April 26, 2008, 03:05:53 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

Offline Moonfisher

  • Bot Overlord
  • ****
  • Posts: 592
    • View Profile
OCULUS
« Reply #1 on: April 26, 2008, 07:44:58 AM »
It's a litle hard to see exactly how it works since you didn't post the eye widths and directions.
But it looks like it's just a priority list where certain eyes are more important than others.
And it sounds like a good idea to find a more clever priority since it can be realy hard to determine which eye is more important.
Distance can ofcourse be a factor (Check out excalibur, it actualy turns towards the closest in sight with just 4 simple genes.)
But IMO distance is not enough, just because something is closer it doesn't always mean it's more important. Often the closest bots will be friendlies and it will distract your bot from incoming enemies.
Also you need to secure against endless loops where you keep switching between 2 friendlies...
I know movement prevents most kind of loops, but it's still anoying when your bot is spending too much time looking at it's own.

In Pacifist I used a very simple gene to switch the eyes, and oddly enough none of the more clever methods I tryed could beat it. It just seems like constantly switching the eyefocus was more effective than trying to pick "the right eye".
I even tryed something involving timestampt for eyes getting checked and prioriti lists that would make sure everything in sight got checked... and it worked fine, but had no noticable diference compared to just switching every cycle.

Used this gene :
cond
*.eyef 0 =
*.refshoot *.myshoot = or 'or whatever your conspec is
start
*.robage 9 mod 4 sub .focuseye store
stop

And believe I know how this looks, but as people keep saying, KISS (Keep It Simple Stupid).
It works, better than most systems I made, and aswell as the best one I could make at the time.
And it can beraly get any simpler.
In case someone is confused about the mod operator (Noticed noone ever uses it), it's realy simple, there is nothing advanced about mod (modulus).
*.robage 9 mod : The simples way I can explain this is that it will substract 9 as many times as possible without turning negative. So 18 9 mod would return 0, 20 9 mod would return 2, and so forth.

I have however finaly managed to get a better eye system to work, it worked well enough t build an entire bot from the way the eyes worked. It's the fastest way I've found to spot enemies so far, not perfect but the code I made is designed to be easy to tweek and adjust so people can find the perfect combination.

It basicaly moves all the eyes to one side and uses eye9 as focuseye, it allows you to choose a width and spread for the eyes, and the it simply jumps to the next eye that isn't empty if theres no enemy in eye9.
Again this sounds very simple, because it is, but it works realy well, and much better than what I was trying with distance.
The thing is it doesn't realy matter how far away something is, what matters is to find out what everything around you is as fast as possible, so you can engage first.
The new eye system is the one used in Spinner. I'd recomend trying it out and see if you get inspired.
The first version of spinner has the eyes and not much else (And actualy does rather well dispite the short and simple code in it). The newer version do more stuff... I'm not sure if v1.2 is actualy better than v1.1... I think I'll tweek v1.2 this weekend, I think the reason v1.2 sometimes has problems is some bad tweeks in it's new functions. (v1.2 has a nice conspec and is generaly easy to change and tweek)

Either way I recomend taking a look at Spinner and maybe playing around with the constants, you can change the whole setup for the eyes by changing one or two values, the setup used is faily rough and can easily miss something, the point of the initial setup was to be the first to reach the alge, but I'm considering changing the eyes along the way as the situation changes...

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7719
    • View Profile
OCULUS
« Reply #2 on: April 26, 2008, 02:48:12 PM »
Quote from: Moonfisher
cond
*.eyef 0 =
*.refshoot *.myshoot = or 'or whatever your conspec is
start
*.robage 9 mod 4 sub .focuseye store
stop

You might want to use *.timer instead of *.robage, since *.robage will max out when the bot gets too old, while timer will just wrap around.

Offline bacillus

  • Bot Overlord
  • ****
  • Posts: 907
    • View Profile
OCULUS
« Reply #3 on: April 26, 2008, 06:24:49 PM »
That's the thing with this code; it'll work however you choose to arrange your eyes.
"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 Moonfisher

  • Bot Overlord
  • ****
  • Posts: 592
    • View Profile
OCULUS
« Reply #4 on: April 27, 2008, 06:50:58 AM »
I didn't know there was a *.timer sysvar, that's nice to know.
It's rarely an issue in league fights though, if your bot is 32000 cycles old the fight should have been setled.
But it's never a problem for Pacifist, since it will repro with 99% at the age of 3000, it uses size and age as a conspec...