Author Topic: The NextElement bug  (Read 3720 times)

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
The NextElement bug
« on: October 27, 2005, 10:58:16 AM »
Quote
I still don't know where to go to make that change you suggested!!!!

It's in the place where the original error occured.

The nextElement function in the Mutations module.

here it is again.

Code: [Select]
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 beginning > 0 And beginning < uboundarray Then  'change this line.
    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
    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

Change the line labeled with 'change this line.

from

Code: [Select]
If beginning > 0 Then  'change this line.
to

Code: [Select]
If beginning > 0 And beginning < uboundarray Then  'change this line.
It will fix the overflow problem caused when a robot has zero DNA length
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline Griz

  • Bot Overlord
  • ****
  • Posts: 608
    • View Profile
The NextElement bug
« Reply #1 on: October 27, 2005, 11:26:59 AM »
Quote
It's in the place where the original error occured.
please understand ... this error is not one I got ... [yet] ;) ...
so the debugging did not bring me to it ...
and you hadn't mentioned the Mutations modual at all.
you see?
now that I know where it is ... ;)

thanks
不知
~griz~
[/color]
   "The selection of Random Numbers is too important to be left to Chance"
The Mooj  a friend to all humanity
[/color]

Offline Ulciscor

  • Moderator
  • Bot Destroyer
  • *****
  • Posts: 401
    • View Profile
The NextElement bug
« Reply #2 on: October 27, 2005, 12:14:40 PM »
NextElement bug is fixed then? Cool.
:D Ulciscor :D

I used to be indecisive, but now I'm not so sure.