Darwinbots Forum

Bots and Simulations => DNA - General => The Gene depository => Topic started by: MacadamiaNuts on January 19, 2007, 12:03:49 PM

Title: 1G reference
Post by: MacadamiaNuts 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)
Title: 1G reference
Post by: Jez on January 20, 2007, 05:02:32 AM
Have you read the Conditionless bots (http://www.darwinbots.com/WikiManual/index.php?title=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.  
Title: 1G reference
Post by: MacadamiaNuts 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
Title: 1G reference
Post by: Jez 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!