Author Topic: About stack  (Read 3016 times)

Offline Peksa

  • Bot Destroyer
  • ***
  • Posts: 118
    • View Profile
About stack
« on: April 02, 2007, 07:39:28 PM »
I'm trying to decipher some evolved dna and it seems to use stack in very, very complicated ways. I think it just puts some numbers in dna and uses them much later, so I'd like to know some things about stacks and about what you can or can't do in different parts in dna.

Wiki says that there's two stacks, correct me if I got anything wrong.
1. Conditional stack, which gets anded together, as far as I understand, at the next start or else command. I found some post in the forum that says that empty condition stack is considered true to all condition-commands.
2. Integer stack, which is zeroed after DNA execution. Empty stack is considered 0.

So the questions:
Does the anded conditions, 1 or 0, stay for the next conditional stack or is the stack considered empty, ie true to everything?
What happens to conditional stack if there is no start or else command before next conditions command?
When comparing a value to empty comditional stack, is it also considered true?
Is it possible to compare (or use any conditional commands like and or xor) in integer stack?
If not, what happens if you try to do it anyway?
Is it possible to do math in conditions?
What happens to store command when it's not between start, else and stop?
What happens to input between genes?

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
About stack
« Reply #1 on: April 02, 2007, 11:40:09 PM »
The condition stack is strictly for boolean true/false values.  Only comparison and logical operators (>=, and, etc.) modify the conditions stack.  Math, numbers, etc. always happen in the integer stack.

For instance, the statement 5 6 > pushes 5 and 6 onto the integer stack.  > pulls those values from the integer stack, compares them, and pushes the result onto the condition stack.

Whenever a start or else statement is encountered, the conditions stack is ANDed together.  If the resultant value is appropriate (true for start, false for else), then the block is executed.  Otherwise flow continues to the executable section.

By default, the stack contains true.

You can use conditional logic soley in the integer stack if you like using "conditionless logic".  Basically you use the fact that storing to 0 is a free action.  There are other topics on the subject.

Store commands are disabled if they are not in an executing start or else block.  Commands that are outside of a proper block, or in a non executing block, are entirely ignored.

If two condition blocks occur back to back, its the latter conditional block that gets used for the next start or else block.  The first is executed, but its result gets overwritten.

Last, a single condition block can control multiple consecutive start or else blocks if there are no other condition blocks along the way.