Author Topic: Stores not executed in 'else' blocks  (Read 3516 times)

Offline Sprotiel

  • Bot Destroyer
  • ***
  • Posts: 135
    • View Profile
Stores not executed in 'else' blocks
« 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

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Stores not executed in 'else' blocks
« Reply #1 on: December 17, 2006, 03:03:53 AM »
That's a pretty fundamental error, I'm suprised it hasn't been caught until now.

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Stores not executed in 'else' blocks
« Reply #2 on: December 18, 2006, 06:44:19 PM »
I guess very few people use else conditions...

Fixed in 2.42.9p.
Many beers....

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Stores not executed in 'else' blocks
« Reply #3 on: December 18, 2006, 10:44:36 PM »
like no one

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
Stores not executed in 'else' blocks
« Reply #4 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!  
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Stores not executed in 'else' blocks
« Reply #5 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.

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
Stores not executed in 'else' blocks
« Reply #6 on: December 19, 2006, 06:13:21 AM »
Bah! Let the program design the bots I say!  
The internet is corrupt and controlled by criminally minded people.