Author Topic: runtime 6/compile error  (Read 23819 times)

Offline Griz

  • Bot Overlord
  • ****
  • Posts: 608
    • View Profile
runtime 6/compile error
« on: October 27, 2005, 08:12:04 PM »
ok.
attn Nums!!!!!!!!!

I reported this before.

I keep getting this same runtime error 6 overflow.
in the Senses modual ... lookoccurr routine.
rob(o).vx is out of range.

now ...
you said the following would fix this ...
but you didn't specify if all of this had to be changed or where to insert it.

~~~
if abs(rob(o).vx) > rob(o).MaxVel then rob(o).vx = sgn(rob(o).vx) * rob(o).MaxVel
if abs(rob(o).vy) > rob(o).MaxVel then rob(o).vy = sgn(rob(o).vy) * rob(o).MaxVel

rob(n).mem(refvelup) = (rob(o).vx * Cos(rob(n).aim) + rob(o).vy * Sin(rob(n).aim) * -1) - rob(n).mem(velup)
rob(n).mem(refveldn) = rob(n).mem(refvelup) * -1
rob(n).mem(refveldx) = (rob(o).vy * Cos(rob(n).aim) + rob(o).vx * Sin(rob(n).aim)) - rob(n).mem(veldx)
rob(n).mem(refvelsx) = rob(n).mem(refvelsx) * -1
~~~

please, please, please, please ...
would you tell me exactly where in the following rountine this code goes ...
because if I put this at the top of the routine ...
I get a compile error ...
"method or data member not found."
and this highlighted:
Public Sub lookoccurr(n As Integer, o As Integer)

you guys want us to be specific when reporting the bugs ....
would you please be as specific with the fixes? ;)

and/or ...
might someone who now has a stable 2.37.4 upload it as 2.37.4b or something.
I sure would like to be running it as well.

thank you
~griz~


~~~~~~~~~~~~~~~~
' copies the occurr array of a viewed robot
' in the ref* vars of the viewing one
Public Sub lookoccurr(n As Integer, o As Integer)
  If rob(n).Corpse Then Exit Sub
  Dim t As Byte
  'If rob(n).lastviewed <> rob(o).AbsNum Then
    For t = 1 To 8
      rob(n).mem(occurrstart + t) = rob(o).occurr(t)
    Next t
    rob(n).lastviewed = rob(o).AbsNum
  'End If
  If rob(o).nrg < 32001 Then
    rob(n).mem(occurrstart + 9) = rob(o).nrg
  Else
    rob(n).mem(occurrstart + 9) = 32000
  End If
  rob(n).mem(occurrstart + 10) = rob(o).age '.refage
  rob(n).mem(in1) = rob(o).mem(out1)
  rob(n).mem(in2) = rob(o).mem(out2)
  rob(n).mem(711) = rob(o).mem(18)      'refaim
  rob(n).mem(712) = rob(o).occurr(9)    'reftie
  rob(n).mem(refshell) = rob(o).Shell
  rob(n).mem(refbody) = rob(o).body
  rob(n).mem(refypos) = rob(o).mem(217)
  rob(n).mem(refxpos) = rob(o).mem(219)

if abs(rob(o).vx) > rob(o).MaxVel then rob(o).vx = sgn(rob(o).vx) * rob(o).MaxVel
if abs(rob(o).vy) > rob(o).MaxVel then rob(o).vy = sgn(rob(o).vy) * rob(o).MaxVel


  'give reference variables from the bots frame of reference
  rob(n).mem(refvelup) = (rob(o).vx * Cos(rob(n).aim) + rob(o).vy * Sin(rob(n).aim) * -1) - rob(n).mem(velup)
  rob(n).mem(refveldn) = rob(n).mem(refvelup) * -1
  rob(n).mem(refveldx) = (rob(o).vy * Cos(rob(n).aim) + rob(o).vx * Sin(rob(n).aim)) - rob(n).mem(veldx)
  rob(n).mem(refvelsx) = rob(n).mem(refvelsx) * -1
  rob(n).mem(refvelscalar) = CInt((CLng(rob(n).mem(refvelup)) ^ 2 + CLng(rob(n).mem(refveldx)) ^ 2) ^ 0.5)

'replaced following line. overflow
  'rob(n).mem(refvelscalar) = Sqr(rob(n).mem(refvelup) ^ 2 + rob(n).mem(refveldx) ^ 2) ' how fast is this robot

moving compared to me?
  rob(n).mem(713) = rob(o).mem(827)     'refpoison. current value of poison. not poison commands
  rob(n).mem(714) = rob(o).mem(825)     'refvenom (as with poison)
  rob(n).mem(715) = rob(o).kills        'refkills
   If rob(o).Multibot = True Then
    rob(n).mem(refmulti) = 1
  Else
    rob(n).mem(refmulti) = 0
  End If
  If rob(n).mem(474) > 0 And rob(n).mem(474) <= 1000 Then 'readmem and memloc couple used to read a

specified memory location of the target robot
    rob(n).mem(473) = rob(o).mem(rob(n).mem(474))
    'rob(n).mem(474) = 0
  End If
  If rob(o).Fixed Then                  'reffixed. Tells if a viewed robot is fixed by .fixpos.
    rob(n).mem(477) = 1
  Else
    rob(n).mem(477) = 0
  End If
  rob(n).mem(825) = rob(n).venom
  rob(n).mem(827) = rob(n).poison
   
End Sub

There, fix should be self evident (unless you're color blind ;))
« Last Edit: October 27, 2005, 09:21:28 PM by Numsgil »
不知
~griz~
[/color]
   "The selection of Random Numbers is too important to be left to Chance"
The Mooj  a friend to all humanity
[/color]

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
runtime 6/compile error
« Reply #1 on: October 27, 2005, 08:14:58 PM »
I've posted changes in your post in red.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
runtime 6/compile error
« Reply #2 on: October 27, 2005, 09:17:41 PM »
Griz says it's still crashign so whoever actually attempts to fix this bug in an official version double check over everything.  The idea should be basically sound...

Offline Ulciscor

  • Moderator
  • Bot Destroyer
  • *****
  • Posts: 401
    • View Profile
runtime 6/compile error
« Reply #3 on: October 27, 2005, 09:19:35 PM »
OK then, so the fix doesn't work. It's back in reports so people can say what happened, if there was any change using the fix, etc.   ^_^

OK?
:D Ulciscor :D

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

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
runtime 6/compile error
« Reply #4 on: October 28, 2005, 09:11:16 AM »
OK, this is my task for the day. To figure out what is wrong with this routine.

Has anyone else ever seen this error? and if so, how do I reproduce it because I can't get it to break.  :(
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
runtime 6/compile error
« Reply #5 on: October 28, 2005, 09:14:37 AM »
Are we saying that rob(o).vx is a whole lot bigger than it should be?

I'm not seeing it
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
runtime 6/compile error
« Reply #6 on: October 28, 2005, 09:25:31 AM »
Probably since you're subtracting velup at the end, and velocity was insanely huge prior, that's where the problem is.

abs(velup) should be less than MaxVel I think.

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
runtime 6/compile error
« Reply #7 on: October 28, 2005, 09:27:41 AM »
It certainly should.

In fact since the addition of the maxvel variable I don't think I have ever seen an insanely large velocity. That's why I put Maxvel in, to stop this kind of stuff dead. Thought it had!  :(
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
runtime 6/compile error
« Reply #8 on: October 28, 2005, 09:30:18 AM »
You could check all the routines that modify velocity to see if they're bounds checked against MaxVel.

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
runtime 6/compile error
« Reply #9 on: October 28, 2005, 09:37:44 AM »
There is something weird going on here.  :blink:

In this code there is no such thing as .MaxVel

It simply does not exist as a data member of rob() so your lines of code would actually cause a crash.

I added MaxVel as a data member of rob() ages ago so where the F%$# has it gone?  :blink:
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
runtime 6/compile error
« Reply #10 on: October 28, 2005, 10:11:52 AM »
I just remembered what happened.

.MaxVel never existed.

maxvel was added as a sysvar and is based on a local variable called "Maxspeed" that is calculated in subroutine "updpos" in the Physics module.

The formula for Maxspeed is

Code: [Select]
Maxspeed = 30 / (.mass / 2)
Since robots are supposed to have a minimum mass of 1, this results in a ceiling value of 60

I have extensively tested the actual speed limit code (also found in the same subroutine) by manually entering all kinds of weird and huge numbers into .vx and/or .vy and can safely say there is nothing wrong with this part of the code.

Code: [Select]
vt = Sqr(.vx ^ 2 + .vy ^ 2)
    If vt > Maxspeed Then     'top speed limit routine 2 changed faster speeds for lower mass robots
       Reduce = vt / Maxspeed
      .vx = .vx / Reduce
      .vy = .vy / Reduce
    End If

So the only thing left is that somehow the mass of the robot is getting too small so that Maxspeed is coming back huge.

So I'm off to test that now.
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
runtime 6/compile error
« Reply #11 on: October 28, 2005, 10:42:45 AM »
Next update.

Robot mass is defined in routine "updvars2" in the "Robots" module

Code: [Select]
.mass = 1 + (.body / 10000) + (.Shell / 200)   'set value for mass
    Maxspeed = 30 / (.mass / 2) 'Set maximum speed. Absolute max = 60

You will note that the same Maxspeed calculation is in here too. This one is applied to limit acceleration vectors prior to passing the program flow to the afore mentioned "updpos" routine

As you will see from this formula, the only way to make Maxspeed bigger than 60 is to have a mass of less than 1.
this can be achieved in two ways
One way is to have a body size that is large and negative, A body of -10000 would yield infinite Maxvel and would crash the program right here.
Another is for shell to be negative and close to 200 in size.

I have manually put all kinds of values in here and none cause the crashes reported since even a maxspeed value of 32000 doesn't crash anywhere

Since the reported crashes only occur when one robot sees another with a huge velocity, this isn't really surprising. It could go un-noticed for a few cycles before it becomes an issue.

However, a negative body could not go un-noticed as the bot will die on the following cycle.

Negative shell? Now that is a different matter. It won't have any direct effect on the bots life other than dramatically reducing its mass.

The plot thickens and the delving into the code continues. More in a bit.
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
runtime 6/compile error
« Reply #12 on: October 28, 2005, 10:57:40 AM »
Unable to find any way to make .shell or .body negative. Every test was caught by the automatic limits already in place in the software and set back to a valid value.

The only remote possibility is if the offending robot is a corpse which would allow it to have a negative body (maybe)

I have modified the code in "updvars2" in the robots module as follows

Before

Code: [Select]
With rob(n)
       .mass = 1 + (.body / 10000) + (.Shell / 200)   'set value for mass
    Maxspeed = 30 / (.mass / 2) 'Set maximum speed. Absolute max = 60
    Absaccel = 0                'reset acceleration
    If Abs(.vx) > 32000 Then .vx = 32000 * Sgn(.vx)
    If Abs(.vy) > 32000 Then .vy = 32000 * Sgn(.vy)
    .absvel = Cos(.aim) * .vx * -1 + Sin(.aim) * .vy 'formula changed to give velocity in the direction robot is facing rather than always a positive number. Make *.vel work properly.

after

Code: [Select]
With rob(n)
    If .Shell < 0 Then .Shell = 0
    If .body < 0 Then .body = 0: .Dead = True
    .mass = 1 + (.body / 10000) + (.Shell / 200)   'set value for mass
    Maxspeed = 30 / (.mass / 2) 'Set maximum speed. Absolute max = 60
    Absaccel = 0                'reset acceleration
    If Abs(.vx) > 32000 Then .vx = 32000 * Sgn(.vx)
    If Abs(.vy) > 32000 Then .vy = 32000 * Sgn(.vy)
    .absvel = Cos(.aim) * .vx * -1 + Sin(.aim) * .vy 'formula changed to give velocity in the direction robot is facing rather than always a positive number. Make *.vel work properly.
  

This should prevent any possible huge value of Maxspeed ever occuring.
Without huge Maxspeed, you can't have huge speed so the refvel stuff where the error was actually spotted, should be fixed.

I won't move this to the fixed thread yet until the repair is confirmed.
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
runtime 6/compile error
« Reply #13 on: October 28, 2005, 10:58:18 AM »
Could someone please confirm that Corpses were enabled in sims that produced this fault?
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
runtime 6/compile error
« Reply #14 on: October 28, 2005, 11:04:12 AM »
I allways have corpses turned on so it could very well be. But I'm getting a little confused here now. You're talking about more than one solution here for the same overflow error, is that right? I've lost track what to change first. see my post 'Still get overflows' where you mension another solution.
The internet is corrupt and controlled by criminally minded people.