You can eather
A. Keep my fix , or
B. Write your own fix if you think my method is too drastic
[you]The areas in bold are the changed areas[/you]
#1 Beggining was returning After the Bounds of the erray
Public Function NextElement(ByRef DNA() As block, beginning As Integer, tipo As Integer, value As Integer) As Integer
'takes the input for the first value in a gene and returns the position of the next statement
'as defined by tipo and value
Dim k As Integer
Dim uboundarray As Long
uboundarray = UBound(DNA())
If DNA(uboundarray).tipo <> 4 And DNA(uboundarray).value <> 4 Then
ReDim Preserve DNA(uboundarray + 1)
DNA(uboundarray + 1).tipo = 4
DNA(uboundarray + 1).value = 4
End If
k = beginning
If UBound(DNA) <= k Then
DNA(UBound(DNA)).tipo = 4
DNA(UBound(DNA)).value = 4
k = UBound(DNA)
End If
If beginning > 0 Then
While Not (DNA(k).tipo = 4 And DNA(k).value = 4) And Not (DNA(k).tipo = tipo And DNA(k).value = value)
k = k + 1
If UBound(DNA) <= k Then
DNA(UBound(DNA)).tipo = 4
DNA(UBound(DNA)).value = 4
k = UBound(DNA)
End If
Wend
If Not (DNA(k).tipo = tipo And DNA(k).value = value) Then k = -1
Else 'beginning wasn't valid
k = -1
End If
NextElement = k
End Function
#2 A robot was dumping more then an integer of energy into its child
Public Sub updatepos()
...
bypass:
Set nd = rlist.nextnode(nd)
End With
DoEvents
Wend
'''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''
t = 1
While t < rp
If rep(t) > 0 Then
Dim nomore As Long
nomore = rob(rep(t)).mem(repro) + rob(rep(t)).mem(mrepro)
If nomore < 32000 Then
Reproduce rep(t), CInt(nomore)
rob(rep(t)).mem(repro) = 0
rob(rep(t)).mem(mrepro) = 0
Else
KillRobot rep(t)
End If
ElseIf rep(t) < 0 Then
SexReproduce -rep(t), -rep(t + 1)
rob(-rep(t)).mem(sexrepro) = 0
rob(-rep(t + 1)).mem(sexrepro) = 0
t = t + 1
End If
t = t + 1
Wend
t = 1
While t < kl
KillRobot kil(t)
t = t + 1
Wend
...
#3 Although there is a check if the resulting number is greater then integer, This still does not prevent the numbers to be multiplyed as integers Therefore,
Public sub newshot
...
about 200 body to equal old method range. 32000 body doubles old range
Shots(a).nrg = Shots(a).range
Else
Shots(a).range = RobSize * 3 * rngmultiplier
Shots(a).nrg = RobSize * 3 * rngmultiplier
End If
If shottype = -7 Then
Dim tempa As Single
tempa = CLng(rob(n).mem(338)) * 20 'MUST BE CLNG TO FIX THE ERROR
If tempa <= 32000 Then
Shots(a).nrg = rob(n).mem(338) * 20
Else
KillRobot n
End If
Shots(a).range = Shots(a).nrg
Shots(a).color = vbCyan
End If
Shots(a).value = val
...