Author Topic: Lack of True and False Commands CLOSED 2.43q  (Read 2162 times)

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Lack of True and False Commands CLOSED 2.43q
« on: November 09, 2007, 09:28:08 PM »
The wiki says that the numbers 1 and 0 can be used as True and False in the conditional portion of a gene.  This is incorrect.  As currently implemented, numbers enounterred in the conditional portion of a gene are pushed onto the integer stack, not the boolean stack whereas logical operators such as AND, OR, etc. only operate on values popped from the boolean stack.  Thus, while the wiki claims the following gene should never fire, it in fact always fires.  The boolean stack is in fact empty and thus the two pops perfromed by the AND equate to True.

cond
0 1 and
start
do something
stop

I discoverred this while implementing the new execution paradym where conditional statements are allowed in the body portion of a gene.  What I propose to do is invent two new commands:  True and False, which when encounterred will result in the appropriate boolean value being pushed on the boolean stack.  Numbers (including 0 and 1) will always be pushed on the integer stack whether they are encounterred in the cond or the body portion of a gene.  Boolean operators will always and only operate on values from the boolean stack.  The numbers 0 and 1 will not be substitutes for True and False.  The gene as coded above will continue to always fire (we will need to update the Wiki) but the following gene will not:

cond
false true and
start
do something
stop

This makes encoutering a 0 or 1 in the DNA unambigious, particularly now that conditionals are allowed in the gene body.  It will also allow for a single codon to influence partial gene exection as follows:

start
10 .dn store
false
10 .up store
stop

The false prevents the store to .up from occurring.  Note that in the following gene, both stores occur.  0 is not a substitute for false.

start
10 .dn store
0
10 .up store
stop
« Last Edit: November 14, 2007, 10:52:05 PM by EricL »
Many beers....

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Lack of True and False Commands CLOSED 2.43q
« Reply #1 on: November 10, 2007, 12:02:30 AM »
This is what I've done for DB3, and it's worked rather well.