Bots and Simulations > F3 bots

Slam_Funk2.1(F3)(Ta-183)-5.27.09

<< < (2/3) > >>

Moonfisher:
Actualy the eye system in eyebot is set up with a lot of comments and helping features, to make it more plug and play like...

Eyebot has 2 systems, one for turning to the next non zero eye, and one for changing focus eye.
The system for changing focus eye doesn't rely on any of the other code in eyebot, it will work on it's own.

So the actual code for changing focus eye in eyebot is only one line :
[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']
501 *.focuseye 5 add 9 mod add * abs sgn 501 *.focuseye 6 add 9 mod add * abs sgn 2 mult | 501 *.focuseye 7 add 9 mod add * abs sgn 4 mult | 501 *.focuseye 8 add 9 mod add * abs sgn 8 mult | 501 *.focuseye 9 add 9 mod add * abs sgn 16 mult | 501 *.focuseye 10 add 9 mod add * abs sgn 32 mult | 501 *.focuseye 11 add 9 mod add * abs sgn 64 mult | 501 *.focuseye 12 add 9 mod add * abs sgn 128 mult | dup dup dup dup dup dup dup dup 1 & 1 sub dup div 1 sub abs *.focuseye 5 add 9 mod 4 sub mult swap 3 & 2 sub dup div 1 sub abs *.focuseye 6 add 9 mod 4 sub mult add swap 7 & 4 sub dup div 1 sub abs *.focuseye 7 add 9 mod 4 sub mult add swap 15 & 8 sub dup div 1 sub abs *.focuseye 8 add 9 mod 4 sub mult add swap 31 & 16 sub dup div 1 sub abs *.focuseye 9 add 9 mod 4 sub mult add swap 63 & 32 sub dup div 1 sub abs *.focuseye 10 add 9 mod 4 sub mult add swap 127 & 64 sub dup div 1 sub abs *.focuseye 11 add 9 mod 4 sub mult add swap 255 & 128 sub dup div 1 sub abs *.focuseye 12 add 9 mod 4 sub mult add swap 511 swap sgn mult store


This one line will switch the focus eye to the next non zero eye, if there is one.
It's cheap since it's only one line, and it's very easy to use.

You basicaly just write your condition for whenever you want switch focus and add the line afterwards
(I recommend spreading out the vision in some way (By changing eyedir and eyewidth) to take full advantage of this)

And if you want to keep jumping back to a certain eye you could hack it into doing that aswell (At the cost of a redundant store).
So for instance if you plan to leave eye5 as your center eye, and come back to it every 2 cycles, you could use *.timer 2 mod 0 = (Or 1 =) to make sure you jump to eye5 if it sees something (Or if you remembered the presence of an enemy). You would just have to make sure you make a backup of the focuseye value and reinsert that value in the next cycle before using the line from eyebot.
The focus eye will be changed again in that cycle, you're only resetting the previous value to make sure the eye system continues on it's previous path.

Personaly I find that it isn't nessesary to jump back every 2 cycles, since all the eyes will rarely be full. But maybe if you have wide eyes and a 360 degree vision you'll risk having to wait 8 cycles to see if the alge you where shooting at is still there (That would probably be a problem).

Anyway point being, that one line could be very usefull, it basicaly just jumps to the next non empty eye. (If you need to use the system for turning to the next empty eye you'll also need other parts from eyebot, but I think this is the line you realy need for what you have in mind)

Also if you want to understand how the line works you'll want to look at the broken down version :

[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']
501 *.focuseye 5 add 9 mod add * abs sgn
501 *.focuseye 6 add 9 mod add * abs sgn 2 mult |
501 *.focuseye 7 add 9 mod add * abs sgn 4 mult |
501 *.focuseye 8 add 9 mod add * abs sgn 8 mult |
501 *.focuseye 9 add 9 mod add * abs sgn 16 mult |
501 *.focuseye 10 add 9 mod add * abs sgn 32 mult |
501 *.focuseye 11 add 9 mod add * abs sgn 64 mult |
501 *.focuseye 12 add 9 mod add * abs sgn 128 mult |
dup
dup
dup
dup
dup
dup
dup
dup
1 & 1 sub dup div 1 sub abs
*.focuseye 5 add 9 mod 4 sub
mult
swap
3 & 2 sub dup div 1 sub abs
*.focuseye 6 add 9 mod 4 sub
mult
add
swap
7 & 4 sub dup div 1 sub abs
*.focuseye 7 add 9 mod 4 sub
mult
add
swap
15 & 8 sub dup div 1 sub abs
*.focuseye 8 add 9 mod 4 sub
mult
add
swap
31 & 16 sub dup div 1 sub abs
*.focuseye 9 add 9 mod 4 sub
mult
add
swap
63 & 32 sub dup div 1 sub abs
*.focuseye 10 add 9 mod 4 sub
mult
add
swap
127 & 64 sub dup div 1 sub abs
*.focuseye 11 add 9 mod 4 sub
mult
add
swap
255 & 128 sub dup div 1 sub abs
*.focuseye 12 add 9 mod 4 sub
mult
add
swap
.focuseye
swap
sgn mult
store


But all you realy need to know is what it does, and it's pretty straight forward.

Moonfisher:
Is it just me or do the codeboxes look realy messed up ?

Anyway here's the codebox content again in a quote box.

One liner :

--- Quote ---501 *.focuseye 5 add 9 mod add * abs sgn 501 *.focuseye 6 add 9 mod add * abs sgn 2 mult | 501 *.focuseye 7 add 9 mod add * abs sgn 4 mult | 501 *.focuseye 8 add 9 mod add * abs sgn 8 mult | 501 *.focuseye 9 add 9 mod add * abs sgn 16 mult | 501 *.focuseye 10 add 9 mod add * abs sgn 32 mult | 501 *.focuseye 11 add 9 mod add * abs sgn 64 mult | 501 *.focuseye 12 add 9 mod add * abs sgn 128 mult | dup dup dup dup dup dup dup dup 1 & 1 sub dup div 1 sub abs *.focuseye 5 add 9 mod 4 sub mult swap 3 & 2 sub dup div 1 sub abs *.focuseye 6 add 9 mod 4 sub mult add swap 7 & 4 sub dup div 1 sub abs *.focuseye 7 add 9 mod 4 sub mult add swap 15 & 8 sub dup div 1 sub abs *.focuseye 8 add 9 mod 4 sub mult add swap 31 & 16 sub dup div 1 sub abs *.focuseye 9 add 9 mod 4 sub mult add swap 63 & 32 sub dup div 1 sub abs *.focuseye 10 add 9 mod 4 sub mult add swap 127 & 64 sub dup div 1 sub abs *.focuseye 11 add 9 mod 4 sub mult add swap 255 & 128 sub dup div 1 sub abs *.focuseye 12 add 9 mod 4 sub mult add swap 511 swap sgn mult store
--- End quote ---

Broken down :

--- Quote ---501 *.focuseye 5 add 9 mod add * abs sgn
501 *.focuseye 6 add 9 mod add * abs sgn 2 mult |
501 *.focuseye 7 add 9 mod add * abs sgn 4 mult |
501 *.focuseye 8 add 9 mod add * abs sgn 8 mult |
501 *.focuseye 9 add 9 mod add * abs sgn 16 mult |
501 *.focuseye 10 add 9 mod add * abs sgn 32 mult |
501 *.focuseye 11 add 9 mod add * abs sgn 64 mult |
501 *.focuseye 12 add 9 mod add * abs sgn 128 mult |
dup
dup
dup
dup
dup
dup
dup
dup
1 & 1 sub dup div 1 sub abs
*.focuseye 5 add 9 mod 4 sub
mult
swap
3 & 2 sub dup div 1 sub abs
*.focuseye 6 add 9 mod 4 sub
mult
add
swap
7 & 4 sub dup div 1 sub abs
*.focuseye 7 add 9 mod 4 sub
mult
add
swap
15 & 8 sub dup div 1 sub abs
*.focuseye 8 add 9 mod 4 sub
mult
add
swap
31 & 16 sub dup div 1 sub abs
*.focuseye 9 add 9 mod 4 sub
mult
add
swap
63 & 32 sub dup div 1 sub abs
*.focuseye 10 add 9 mod 4 sub
mult
add
swap
127 & 64 sub dup div 1 sub abs
*.focuseye 11 add 9 mod 4 sub
mult
add
swap
255 & 128 sub dup div 1 sub abs
*.focuseye 12 add 9 mod 4 sub
mult
add
swap
.focuseye
swap
sgn mult
store
--- End quote ---

Ta-183:
I'm sorry, but I can't exactly read what it's doing. I need to go back and look at mod again, I still don't know exactly what it does. I get frustrated when I don't know something. I am also more comfortable with boolean logic than math, so I was thinking more along the lines of using a single gene with multiple 'if exeX greater than 0 and eyetimer is odd and if switchedeyealready is 0 then switch focuseye to X' statements. The 'front-and-next-and' bit is to make sure that fast moving bots do not escape SF's vision, like Aim does to Beholder.

Again, I'm going for simple behavior, complex gene, simple code. I'm used to programming a calculator with a built in BASIC stamp. But don't get me wrong, the calculator itself allowed me to use complex math and trigonometry. I miss my slow-to-a-crawl 3D engine. Damn random RAM resets.

Moonfisher:
Well all that modulus (mod) does is give you the remainder from a dividion between two numbers.
So *.timer 2 mod 0 = will be true when *.timer is even and a division by 2 would have no remainder.
So 26 5 mod would return 1, since 26 is the same as 5*5 + 1.
It's a very usefull opperator.

As for the one line, the first part packs all the logic into the top integer on the stack. (By OR'ing each condition into a given bit)
Each condition is the sgn'ed value of an eye.
Then it makes a lot of copyes of the value on the stack.
And last it can use the integers on the stack to check several eyes at once for every action it might take.
Can't actualy remember exactly what my thought was in this area (And it's hard to read). So can't explain it right now because I can't remember and I just woke up so I don't understand it either
But it ends up switching to the next non empty eye somehow
And by doing it this way it avoids the use of a ton of conditions.

And don't forget to save and reset the previous focus eye every time you've broken the cycle. Otherwise every time you jump to eye5 it'll restarts it's cycles from that point.

Ta-183:
Yeah, basically what it does is when it activates the scan feature, it stops checking weather or not to activate it (so it does not reset the list of eyes to check) and builds a list of eyes, using an incrementing counter to store 1 to up to eight memvars, starting by storing the number of eyes to check and building the list by looking at what eyes are nonzero and storing the eye number to the next empty list slot, building the list by checking each nonzero eye in the order that it would check EVERY eye, (5-6-5-4) excluding eye5 and any zero eye, putting those ID's in the 'list' and then it begins to actually DO crap. It starts out by doing whatever all I'm going to make it do at each eye on eye5, (IFFF readings, bot status, enemy count, etc) then changes the focuseye to the next eye in the list. It increments a counter to look to the next list position, as long as the counter does not exceed the number of eyes to check. Next cycle, it does the same thing to the first nonzero eye on the list, then switches back to eye5.  Of course, each cycle it checks every nonzero eye on the list to make sure that *.eyeX hasn't changed too much so that it can tell if it needs to knock an eye off the list or put a new one in the queue. This won't be the ONLY vision system used on the bots I make that have it. SF2.1's eye system works VERY effectively when it needs to track fast moving or irregular targets, or if energy becomes dangerously low and the scanning-eye system becomes too costly to use. I may also throw in a 'frustration' variable, that goes up if it has to adjust the eye list. The more it has to update (meaning shit's REALLY flying) the more frustrated it gets, and after a certain level it just kinda goes "FUCK IT!" and reverts to the old eyes until stuff cools down, relying on other SF's (like they already do) for food and enemy locations that might be juuuuust out of sight.

Also, I like the idea of a bot that can get pissed off.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version