Darwinbots Forum

Code center => Bugs and fixes => Topic started by: Numsgil on April 16, 2006, 12:30:40 PM

Title: Fixing Stores in 2.4
Post by: Numsgil on April 16, 2006, 12:30:40 PM
THis is in the DNAExecution module:

Code: [Select]
Private Sub ExecuteStores(n As Integer)
   Select Case n
     Case 1 'store
       DNAstore
       rob(currbot).nrg = rob(currbot).nrg - SimOpts.Costs(COSTSTORE)
     Case 2 'inc
       DNAinc
       rob(currbot).nrg = rob(currbot).nrg - SimOpts.Costs(COSTSTORE) / 10
     Case 3 'dec
       DNAdec
       rob(currbot).nrg = rob(currbot).nrg - SimOpts.Costs(COSTSTORE) / 10
     Case 4 '+=
     Case 5 '-=
     Case 6 '*=
     Case 7 '/=
   End Select
 End Sub
 
 Private Sub DNAstore()
   Dim b As Long
   b = PopIntStack
   If b > 0 And b <= MaxMem Then
     rob(currbot).mem(b) = PopIntStack Mod 32000
   End If
 End Sub
 
 Private Sub DNAinc()
   Dim a As Long, b As Long
   a = PopIntStack
  
   If a >= 1 And a <= 1000 Then
     b = (rob(currbot).mem(a) + 1) Mod 32000
     rob(currbot).mem(a) = b
   End If
 End Sub
 
 Private Sub DNAdec()
   Dim a As Long, b As Long
   a = PopIntStack
  
   If a >= 1 And a <= 1000 Then
     b = (rob(currbot).mem(a) - 1) Mod 32000
     rob(currbot).mem(a) = b
   End If
 End Sub

 change this to:
 
 
Code: [Select]
Private Sub ExecuteStores(n As Integer)
   Select Case n
     Case 1 'store
       DNAstore
     Case 2 'inc
       DNAinc
     Case 3 'dec
       DNAdec
     Case 4 '+=
     Case 5 '-=
     Case 6 '*=
     Case 7 '/=
   End Select
 End Sub
 
 Private Sub DNAstore()
   Dim b As Long
   b = PopIntStack
   If b > 0 And b <= MaxMem Then
     rob(currbot).mem(b) = PopIntStack Mod 32000
     rob(currbot).nrg = rob(currbot).nrg - SimOpts.Costs(COSTSTORE)
   End If
 End Sub
 
 Private Sub DNAinc()
   Dim a As Long, b As Long
   a = PopIntStack
  
   If a >= 1 And a <= 1000 Then
     b = (rob(currbot).mem(a) + 1) Mod 32000
     rob(currbot).mem(a) = b
     rob(currbot).nrg = rob(currbot).nrg - SimOpts.Costs(COSTSTORE) / 10
   End If
 End Sub
 
 Private Sub DNAdec()
   Dim a As Long, b As Long
   a = PopIntStack
  
   If a >= 1 And a <= 1000 Then
     b = (rob(currbot).mem(a) - 1) Mod 32000
     rob(currbot).mem(a) = b
     rob(currbot).nrg = rob(currbot).nrg - SimOpts.Costs(COSTSTORE) / 10
   End If
 End Sub

 BTW, does anyone know if there's a way I could just post code and highlight changes in like red?  THe color tags won't work if I have the code tags on.
Title: Fixing Stores in 2.4
Post by: EricL on April 16, 2006, 12:44:43 PM
This change will be in 2.42.3.  Stores to locations outside valid memory will cease to cost anything.
Title: Fixing Stores in 2.4
Post by: Elite on April 16, 2006, 01:00:55 PM
Yey   Now my conditionless bots will work efficiently again

 
Title: Fixing Stores in 2.4
Post by: PurpleYouko on April 17, 2006, 09:12:05 AM
Quote
BTW, does anyone know if there's a way I could just post code and highlight changes in like red? THe color tags won't work if I have the code tags on.
Not without modding the php code somewhat.

try putting the code in quote tags. They look pretty similar these days and color tags work in them  
Title: Fixing Stores in 2.4
Post by: Numsgil on April 17, 2006, 01:13:09 PM
Ah, quotes, there's an idea.