Bots and Simulations > DNA Tools
How DNA works
Gobo:
Eric, thanks a lot! Would you please also post ExecuteFlowCommands function's source?
EricL:
"The memory and both integer and boolean stacks are persistent during a single cycle. It means, that if you leave a value in a stack in one gene, it will be still there when you enter the next gene. "
This is not strictly correct for the boolean stack. As you say, there are no implicit operators on the integer stack. It takes explicit DNA commands to push and pop from the stack and gene boundaries do not have implicit meaning other than marking the boundaries of non-coding regions within which push and pop operations are ignroed.
But gene boundaries implicitly operate on the boolean stack. A cond statement clears the boolean stack for example (a clear stack is implicitly true). A start statement is an implicit AND of all arguments on the boolean stack.
--- Code: ---Private Function ExecuteFlowCommands(n As Integer) As Boolean
'returns true if a stop command was found (start, stop, or else)
'returns false if cond was found
ExecuteFlowCommands = False
Select Case n
Case 1 'cond
CurrentFlow = COND
' Clear the boolean stack
Condst.pos = 0
Condst.val(0) = 0
Exit Function
Case 2, 3, 4 'assume a stop command, or it really is a stop command
'this is supposed to come before case 2 and 3, since these commands
'must be executed before start and else have a chance to go
ExecuteFlowCommands = True
If CurrentFlow = COND Then CurrentCondFlag = AddupCond
CurrentFlow = CLEAR
Select Case n
Case 2 'start
If CurrentCondFlag = NEXTBODY Then CurrentFlow = body
currgene = currgene + 1
Case 3 'else
If CurrentCondFlag = NEXTELSE Then CurrentFlow = ELSEBODY
currgene = currgene + 1
End Select
End Select
End Function
--- End code ---
Gobo:
--- Quote from: EricL ---
--- Code: ---
Case 7 'store, inc and dec
If CurrentFlow = body Or CurrentFlow = ELSEBODY Then
If CondStateIsTrue Then ' Check the Bool stack. If empty or True on top, do the stores. Don't if False.
ExecuteStores .DNA(a).value
If n = robfocus Or Not (rob(n).console Is Nothing) Then rob(n).ga(currgene) = True 'EricL This gene fired this cycle! Populate ga()
End If
End If
--- End code ---
--- End quote ---
WOW! Does it mean, that
--- Code: ---*.nrg 20000 > 50 .repro store
--- End code ---
now works as expected?
EricL:
--- Quote from: Gobo ---WOW! Does it mean, that
--- Code: ---*.nrg 20000 > 50 .repro store
--- End code ---
now works as expected?
--- End quote ---
Yes, exactly. Check out this topic.
Gobo:
--- Quote from: EricL ---But gene boundaries implicitly operate on the boolean stack. A cond statement clears the boolean stack for example (a clear stack is implicitly true). A start statement is an implicit AND of all arguments on the boolean stack.
--- End quote ---
Yep, I noticed it already and changed that para. Though it needs to be rewritten again taking into account the cutting edge wisdom
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version