Author Topic: Let's make a stable platform  (Read 34149 times)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Let's make a stable platform
« Reply #30 on: October 26, 2005, 01:08:29 AM »
Ah, that would be a no, Bots.

The fix isn't too bad.  Store the memrefvelup or whtatever and the other one to longs.  Then square each one and add them together.  Then find the square root.  Then double check to see that that isn't > 32000.

Welcome to my world ;)


Just so we're clear, PY is handling all the debugging of 2.37.4.  I'm working on other things (like robot placement code ;) (speaking of which... Bots, you have heard of thiis little button on the left of the keyboard called a 'tab', right?)

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
Let's make a stable platform
« Reply #31 on: October 26, 2005, 09:19:35 AM »
Quote
Where are you PY??? 

Give me a chance dude.

I only initiated this yesterday and I do actually have a life (and a job) outside DB. Sometimes I can't even get to the code for a week at a time.

Let's start at the beginning. (No offense intended if you already know this stuff)

As Bots suggested, hovering the mouse over a variable is the best way to find out what is wrong.

The most common problem seems to be "overflow"

This simply means that the result of a calculation is too big to fit within the variable type.
Most DB variables are defined as "single" (single precision floating decimal) or "integer". Both of these memory types assign 16 bits of memory to hold the value. That is 1*2*2*2*2*2*2*2*2*2*2*2*2*2*2 possible combinations. Otherwise known as a maximum value of 32,768. We normally limit it to 32000 for an easier life.

So what happens is that some calculation results in a value greater than 32768 then tries to store it into a variable that can't hold it. Instant overflow and the program gives up in disgust.

By hovering the mouse, you can often find the exact variable or calculation that is causing the problem.

You need to report the line of code with as much information about the actual variables as possible. It also helps a lot to report the name of the subroutine in which the code is located. It can be an extremely daunting task just trying to find a specific line of code in the program without a little more info to go on.
In the case of a relatively small routine, just copy the whole routine and put it inside "code" tags in your message. Then describe the problem.

Hopefully I can look into some of this stuff later today.
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Let's make a stable platform
« Reply #32 on: October 26, 2005, 11:57:07 AM »
Haha, okay.  Let's do this bit by bit:

Quote
Here's that Run-Time error 6 bug, appeared after a one hour long simulation.

rob(n).mem(refvelscalar) = Sqr(rob(n).mem(refvelup) ^ 2 + rob(n).mem(refveldx) ^ 2) ' how fast is this robot moving compared to me?

velocity should never be > 60, so theoretically rob(n).mem(refvelup) ^ 2 + rob(n).mem(refveldx) ^ 2 should always be <= 3600, well within the range of an integer.

That it isn't is cause for concern, because it means somewhere something is acting screwy.  Oh well, that's life.  To fix it so this doesn't overflow, we do:

dim temp as single

temp = rob(n).mem(refvelup) ^ 2 + rob(n).mem(refveldx) ^ 2
temp = sqr(temp)

rob(n).mem(refvelscalar) = temp

and then you test it, cause overflow errors like this are always a pain in the butt, and often fixes that should work don't.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Let's make a stable platform
« Reply #33 on: October 26, 2005, 12:05:42 PM »
Quote
Bots, you have heard of thiis little button on the left of the keyboard called a 'tab', right?

 :blink:
I dont get it; Yes I have... and?



MY CODE < USE MY CODE! ... :( ... (What really bugs me is: what if you fix something in some other ways then I fixed it and suddenly 'poof' my robots that I got from my code don't work on your code)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Let's make a stable platform
« Reply #34 on: October 26, 2005, 12:24:48 PM »
And your code lacks standard tabbing.  Things like indenting at the start of a function, for instance.

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
Let's make a stable platform
« Reply #35 on: October 26, 2005, 12:58:57 PM »
That kind of thing makes code almost impossible to debug.

You have to spend ages going through and reformatting things before you can even look at the code itself.

I have debugged other peoples code for them from time to time and invariably, bad formatting is the primary cause for the bug in the first place.

Here is an example of some code that I am fixing for some guy from Mr. Excel

Just check out the crappy formatting.  :blink:

Code: [Select]
Private Sub CommandButton1_Click() 'Enter Button
'Error messages that show if TextBox not filled in
Dim ws As Worksheet
Dim WSQC As Worksheet
    Set ws = Sheets("Time Sheet Compile")
    Set WSQC = Sheets("Quality Control Checks")
        If TextBox4 = "" Then
            MsgBox (" You Have Not Entered The Order Number In The Box Supplied")
                Order_Details.Hide
                    Order_Details.Show
                Else
                    If TextBox5 = "" Then
                        MsgBox (" You Have Not Entered Your Name In The Box Supplied")
                            Order_Details.Hide
                                Order_Details.Show
                            Else
                                If ComboBox1 = "" Then
                                    MsgBox (" You Have Not Entered The Shift Details In The Box Supplied")
                                        Order_Details.Hide
                                     Order_Details.Show
                                  Else
                                If ComboBox2 = "" Then
                            MsgBox (" You Have Not Entered The Machine Details In The Box Supplied")
                        Order_Details.Hide
                    Order_Details.Show
                        Else
                    Confirm_Details.Show
                  End If
               End If
            End If
          End If
        With ws
        ws.Range("A6") = Me.Textbox3.text  'Date
        ws.Range("B6") = Me.TextBox4.text  'Order Number
        ws.Range("C6") = Me.ComboBox1.text 'Shift
        ws.Range("D6") = Me.ComboBox2.text 'Machine
        ws.Range("E6") = Me.TextBox5.text  'Operators Name
        'Copy to Quality Control Checks Sheet
        WSQC.Range("B2") = Me.Textbox3.text 'date
        WSQC.Range("B5") = Me.TextBox4.text  'Order Number
        WSQC.Range("B3") = Me.ComboBox1.text 'Shift
        WSQC.Range("B6") = Me.ComboBox2.text 'Machine
        WSQC.Range("B4") = Me.TextBox5.text  'Operators Name
        WSQC.Range("C11") = Sheets("Time Sheet Archive").Range("AQ6")  'Previous Order Number
        WSQC.Range("D11") = Sheets("Time Sheet Archive").Range("BB6")  'Previous Order's Colour Code
        
        Me.Hide
        QC_Check.Show
        End With
End Sub
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Let's make a stable platform
« Reply #36 on: October 26, 2005, 01:54:15 PM »
:o

Bots, that would be the exact opposite problem you have ;)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Let's make a stable platform
« Reply #37 on: October 26, 2005, 02:10:28 PM »
The 60 maxvelocity is a physical limitation of the visual basic program.

Ideally there'd be no max velocity.  But the physics engine isn't built to cope with that (yet).  Bots would fly right through each other during a cycle without colliding when they should have.

I've raised it to 180 in my code at home to see how stable it is.  Alot of collisions are being missed.

Higher than 180 and you'll get a spate of overflow errors you'd need to fix.

And now you know why I work on the physics engine ;)
« Last Edit: October 26, 2005, 02:10:43 PM by Numsgil »

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
Let's make a stable platform
« Reply #38 on: October 26, 2005, 03:16:53 PM »
Ran a simulation wich lasted for only 5 minutes and then it crashed.

Run-time error 9: Subscript out of range.

Code:

    While Not (DNA(k).tipo = 4 And DNA(k).value = 4) And Not (DNA(k).tipo = tipo And DNA(k).value = value)

Line 108.

It's the code in the mutations window.
« Last Edit: October 26, 2005, 03:18:59 PM by Testlund »
The internet is corrupt and controlled by criminally minded people.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Let's make a stable platform
« Reply #39 on: October 26, 2005, 03:22:16 PM »
That means a bit of DNA wasn't ending with "end" like it should I think.  tipo = 4 and value = 4 is the old code for "end".
« Last Edit: October 26, 2005, 03:22:51 PM by Numsgil »

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
Let's make a stable platform
« Reply #40 on: October 26, 2005, 03:36:00 PM »
I can't make the bloody thing crash period.

I have been running a sim all day with insanely high mutation rates. Nothing I do can put a dent in it yet.
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Let's make a stable platform
« Reply #41 on: October 26, 2005, 03:38:00 PM »
It's the developer's curse.  Only people who can't fix bugs can ever find them. ;)

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
Let's make a stable platform
« Reply #42 on: October 26, 2005, 03:39:59 PM »
Quote
Ran a simulation wich lasted for only 5 minutes and then it crashed.

Run-time error 9: Subscript out of range.

Code:

    While Not (DNA(k).tipo = 4 And DNA(k).value = 4) And Not (DNA(k).tipo = tipo And DNA(k).value = value)

Line 108.

It's the code in the mutations window.
is this "public function NextElement" by any chance?

What are the values of k, DNA(k).value and DNA(k).tipo?
« Last Edit: October 26, 2005, 03:41:37 PM by PurpleYouko »
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
Let's make a stable platform
« Reply #43 on: October 26, 2005, 04:32:05 PM »
Quote
I can't make the bloody thing crash period.

I have been running a sim all day with insanely high mutation rates. Nothing I do can put a dent in it yet.
That makes me think there is something else outside the program that is causing it. ..or maybe you are running with other settings then me. Could it matter what kind of operating system one is using? I'm using Win XP Professional with Service Pack 2.

Also, you guys want me to hover the mouse over the values and tell me what it says. Does that mean you don't have the same values as me on the same code? Allmost every letter in the code shows a popup displaying a value. I found it difficult to report about it, but if that's the way it has to be than I'll give it a try. Starting up another sim.....   :tantrum:
The internet is corrupt and controlled by criminally minded people.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Let's make a stable platform
« Reply #44 on: October 26, 2005, 04:34:31 PM »
When you hover your mouse over code, it's telling you what that bit equals at that exact moment.