Darwinbots Forum
Bots and Simulations => DNA - General => DNA Tools => Topic started by: Gobo on November 27, 2007, 05:38:42 AM
-
I'm going to write evolved DNA deobfuscator, and it is essential to understand perfectly how DNA works. Please check, if my explanation is precise.
http://www.darwinbots.com/WikiManual/index...her_Explanation (http://www.darwinbots.com/WikiManual/index.php?title=Gene#Another_Explanation)
-
For 2.43 it looks correct. However, with recent changes to the way DNA is handled, it changes things slightly. Conditions can now be executed inside the body of genes.
-
Hmmm... When has this change been applied? Because trunk (http://opensvn.csie.org/DarwinbotsVB/trunk/DNA.bas) has:
Case 5 'conditions
If CurrentFlow = COND Then
ExecuteConditions .DNA(a).value
End If
Case 6 'logic commands (and, or, etc.)
If CurrentFlow = COND Then
ExecuteLogic .DNA(a).value
End If
Or is it 2.43 on the trunk? Where can I see the latest source then?
-
Eric hasn't released the latest source since 2.43. There's some sensitive information in it, too, so I'm not sure how or when we're going to release it generally. But I'm sure Eric'll be kind enough to copy+paste the relevant code here.
Also, Eric hasn't been using the SVN, so I'm not sure what version I have in there
-
Case 5 'conditions
'EricL 11/2007 New execution paradym. Conditions can now be executeed anywhere in the gene
If CurrentFlow = COND Or CurrentFlow = body Or CurrentFlow = ELSEBODY Then
ExecuteConditions .DNA(a).value
End If
Case 6 'logic commands (and, or, etc.)
'EricL 11/2007 New execution paradym. Conditions can now be executeed anywhere in the gene
If CurrentFlow = COND Or CurrentFlow = body Or CurrentFlow = ELSEBODY Then
ExecuteLogic .DNA(a).value
End If
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
I'll post the sorce less the password information for 2.43t later today.
-
Eric, thanks a lot! Would you please also post ExecuteFlowCommands function's source?
-
"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.
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
-
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
WOW! Does it mean, that
*.nrg 20000 > 50 .repro store
now works as expected?
-
WOW! Does it mean, that
*.nrg 20000 > 50 .repro store
now works as expected?
Yes, exactly. Check out this topic (http://www.darwinbots.com/Forum/index.php?showtopic=2299).
-
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.
Yep, I noticed it already and changed that para. Though it needs to be rewritten again taking into account the cutting edge wisdom
-
Yes, exactly. Check out this topic (http://www.darwinbots.com/Forum/index.php?showtopic=2299).
Cool! I think, it means I can make Sanger do if-then-else blocks without limitations!
-
Cool! I think, it means I can make Sanger do if-then-else blocks without limitations!
Indeed, I think that it does too.
-
I made a partly-functioning DNA deobfuscator about a year ago, in Python. Obviously, it used 2.43 syntax and is now obsolete, but I'll try to see if it can be updated. If there's any way I can help you, Gobo, please ask.
-
I made a partly-functioning DNA deobfuscator about a year ago, in Python. Obviously, it used 2.43 syntax and is now obsolete, but I'll try to see if it can be updated. If there's any way I can help you, Gobo, please ask.
Sure, would you share your code? I speak Pythonese a bit
-
Sure, would you share your code?
Certainly. Here it is.
-
I'll post the sorce less the password information for 2.43t later today.
Did you ? I can't find it anywhere.
-
Not yet.
-
2.43u source code (http://www.darwinbots.com/FTP/Darwinsource2.43u.zip)