Darwinbots Forum

Code center => Bugs and fixes => Topic started by: Sprotiel on December 17, 2006, 01:54:39 AM

Title: Stores not executed in 'else' blocks
Post by: Sprotiel on December 17, 2006, 01:54:39 AM
For my demonstration, I used an Animal_Minimalis slightly modified to have a search pattern in wide irregular circles.

If for the first gene, I use
Code: [Select]
cond
0 1 =
start
10 .up store
else
10 .up store
stop
bots stay put while turning when they see nothing instead of describing wide circles. However, the code should be correct because replacing the condition with '0 0 =' yields expected behaviour.

To get the else block to execute properly, I need to write:
Code: [Select]
cond
0 1 =
start
10 .up
else
10 .up
stop

cond
start
store

Obviously, the problem comes from store instructions not being executed inside the 'else'-block.

Solution: in Private Sub ExecuteDNA(n As Integer), replace the second line of
Code: [Select]
      Case 7 'store, inc and dec
        If CurrentFlow = body Then
by
Code: [Select]
If CurrentFlow = body Or CurrentFlow = ELSEBODY Then
Title: Stores not executed in 'else' blocks
Post by: Numsgil on December 17, 2006, 03:03:53 AM
That's a pretty fundamental error, I'm suprised it hasn't been caught until now.
Title: Stores not executed in 'else' blocks
Post by: EricL on December 18, 2006, 06:44:19 PM
I guess very few people use else conditions...

Fixed in 2.42.9p.
Title: Stores not executed in 'else' blocks
Post by: Numsgil on December 18, 2006, 10:44:36 PM
like no one
Title: Stores not executed in 'else' blocks
Post by: Jez on December 18, 2006, 11:33:11 PM
Oy! I would if I were writing bots atm, the first time I tried using it in bots it didn't work anyway, but with all the new improvements since I shall astound you all, at some point in the future  , with a new generation of bots that will Else the rest of the bots into wishing they didn't exist!  
Title: Stores not executed in 'else' blocks
Post by: Numsgil on December 18, 2006, 11:57:06 PM
Else will particularly be useful when codules get implemented.  It will basically allow some rather complex decision forking.  I'm working on a bot prototype that would use codules to see how coding with codules will work.
Title: Stores not executed in 'else' blocks
Post by: Testlund on December 19, 2006, 06:13:21 AM
Bah! Let the program design the bots I say!