Author Topic: 1G reference  (Read 1481 times)

Offline MacadamiaNuts

  • Bot Destroyer
  • ***
  • Posts: 273
    • View Profile
    • http://www.franontanaya.com/blog/
1G reference
« on: January 19, 2007, 12:03:49 PM »
I thought it would be interesting if we post all the 1G codes for conditional operators.

I wonder if a 1G version of the code could be built so conditional operators worked like these math operations (nullifying the last stack value if not true), and there weren't any 'conds' 'starts' or 'stops', nor a boolean stack, just stores.

Telling from memory... I guess there may be simpler versions...

Usage: *value .sysvar x y (1G code) store

Example: -1 .shoot *.refeye *.myeye sub abs sgn mult store

If target has 4 eyes and me 3: sub (4 3) = 1; sgn(1) = 1; abs(1) = 1; mult (.shoot 1) = .shoot
If target has 1 eye and me 3: sub (1 3) = -2; sgn(-2) = -1; abs (-1) = 1; mult (.shoot 1) = .shoot
If target has 3 eyes and me 3: sub (3 3) = 0, sgn(0) = 0, abs(0) = 0; mult (.shoot 0) = 0

Code:

Equal: sub abs sgn 1 sub abs mult (or: sub abs sgn -- abs mult)

Not equal: sub abs sgn mult

X bigger than Y: sub sgn 1 sub sgn 1 add mult (or: sub sgn -- sgn ++ mult)

X smaller than Y: sub sgn -1 mult 1 sub sgn 1 add mult (or: sub sgn -1 mult -- sgn ++ mult)

X bigger than or equal to Y: sub 1 add sgn 1 sub sgn 1 add mult (or: sub ++ sgn -- sgn ++ mult)

X smaller than or equal to Y: sub 1 add sgn -1 mult 1 sub sgn 1 add mult  (or: sub ++ sgn -1 mult -- sgn ++ mult)

X beyond Y range: div sgn abs mult

X within Y range: div sgn abs 1 sub abs mult (or: div sgn abs -- abs mult)
« Last Edit: January 19, 2007, 12:09:12 PM by MacadamiaNuts »
Sometimes you win, and sometimes you lose...

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
1G reference
« Reply #1 on: January 20, 2007, 05:02:32 AM »
Have you read the Conditionless bots part of the wiki? Last time I wrote a 1G that had most of the info I needed. If you can find any info missing from that post you are welcome to add it.
The wiki is a group effort after all.  

I'm not bright eyed and bushy tailed enough atm to think of any steps you have missed but I'll have another look later.  
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams

Offline MacadamiaNuts

  • Bot Destroyer
  • ***
  • Posts: 273
    • View Profile
    • http://www.franontanaya.com/blog/
1G reference
« Reply #2 on: January 20, 2007, 02:03:03 PM »
Oh I see... So that's how floor works. I never checked it, just got puzzled when saw it in evo bots. xD
Sometimes you win, and sometimes you lose...

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
1G reference
« Reply #3 on: January 20, 2007, 11:19:39 PM »
All the info for writing bots 'should' be in the wiki.

If you can't find the stuff you need there then please feel free to point it out on the forum.

It is, in essence, a volunteer effort but sometimes it needs a little extra push to get the work done!  
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams