When I made my first 1-gene bot last year, it took me about two weeks to fully understand how they worked. So in case you might have those same problems, I have made a quick guide on how to make them, including an explanation.

Every command can be compressed into the basic formats:

CONDITION VALUE mult LOCATION store

or

VALUE LOCATION CONTIDION mult store

The Condition

The condition is a number, either 1(true) or 0(false). In the first format, the value is multiplied with this, so false returns 0 and true returns 1. Use this if you need to overwrite a certain memory location Easy enough?

The second one is more efficient; it multiplies the location instead of the value; so true stores in the correct memory location, false in memory location 0, where a store is useless, but free (whereas storing 0 in the desired location costs nrg).

Calculating the Condition from numbers A and B

Negation

A -- abs

If A is 1(true), it turns into 0(false)

If A is 0(false), it turns into -1, then 1(true)

Equals

A B sub sgn abs -- abs

If A equals B, the sub command will return 0; otherwise, it will return something else. The sgn command turns this something else into 1 or -1, depending if it's negative or positive. The abs makes sure its 1 in either case. So:

A B != => 1

A B = 0

next, we negate the value:

A B != => 0

A B = => 1

There you go!

Comparing

A B sub sgn 1 add sgn

A and B are subtracted and sgn value taken:

A < B => -1

A = B => 0

A > B => 1

1 is added:

A < B => 0

A = B => 1

A > B => 2

sgn value taken again

A < B => 0

A = B => 1

A > B => 1

A >= B => 1

To get A <= B, flip a and b in the formula. To get A > B, negate A <= B. To get A < B, negate A >= B.

Operators

AND

ConditionA conditionB mult

If both are 1, the result will be 1*1=1.

NOT

ConditionA conditionB mult -- abs

AND value negated.

OR

Calculating the Condition from numbers A and B

Equals

A B sub sgn abs -- abs

If A equals B, the sub command will return 0; otherwise, it will return something else. The sgn command turns this something else into 1 or -1, depending if it's negative or positive. The abs makes sure its 1 in either case. So:

A B != => 1

A B = 0

next, we negate the value:

A B != => 0

A B = => 1

There you go!

Comparing

A B sub sgn 1 add sgn

A and B are subtracted and sgn value taken:

A < B => -1

A = B => 0

A > B => 1

1 is added:

A < B => 0

A = B => 1

A > B => 2

sgn value taken again

A < B => 0

A = B => 1

A > B => 1

A >= B => 1

To get A <= B, flip a and b in the formula. To get A > B, negate A <= B. To get A < B, negate A >= B.

Operators

AND

ConditionA conditionB mult

If both are 1, the result will be 1*1=1.

OR

ConditionA conditionB add sgn

if both are 0, it will add to 0 and sgn will return 0. If one of them is 1, 1 will be returned, and if both are 1, 2 will be returned. Either way, sgn reduces it to 1.

XOR

ConditionA conditionB add -- abs -- abs

A=0, B=0 => 0 => -1 => 1 => 0

A=1, B=1 => 2 => 1 => 1 => 0

One is 1, other is 0 => 1 => 0 => 0 => -1 => 1

EDIT-Better comparators

Greater or equal

**ConditionA conditionB sub sgn 0 floor ++ abs** is the same as A B >=

**ConditionA conditionB sub sgn - 0 floor ++ abs** is the same as A B <=

I hope I have made this clear enough for you to get the basic idea.