Code center > Solved Bugs
runtime 6/compile error
PurpleYouko:
--- Quote ---
--- Quote --- find this section of code in "Updatepos"
--- Code: ---If .mem(216) <> 0 Then
.Fixed = True
.vx = 0
.vy = 0
Else
.Fixed = False
End If
--- End code ---
and change it to
--- Code: ---If .mem(216) <> 0 Then
.Fixed = True
Else
.Fixed = False
End If
if .Fixed then
.vx = 0
.vy = 0
Endif
--- End code ---
--- End quote ---
The two are logically identical (that is, they both do the same thing).
--- End quote ---
Actually they aren't quite the same thing.
The first one sets .fixed to true or false depending on the value in the sysvar .fixpos
It also sets .vx and .vy to zero at this point
The second one takes the .vx and .vy resets out of the sysvar conditional and resets them whenever .fixed is true since it is quite possible for .fixed to be true without the corresponding sysvar value.
Take veggies that are fixed from the GUI or bots that are fixed due to Altzheimers
PurpleYouko:
--- Quote ---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.
with:
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.
???
btw ... I just commented out the old code ... just in case. wink.gif
--- End quote ---
This is in the physics module right?
Then it won't work.
The reason is that for any robot that is fixed, this entore routine is skipped.
If the code in this routine is actually executed then it works perfectly every time without the added limits. No matter what values of .vx and .vy come in here, they always come out at less than Maxspeed (60)
If you want this routine to work, take out the conditional at the top which excluded fixed bots. Then you don't even need to add lines of code. This was answer one in my previous options.
PurpleYouko:
The root cause of all this crap is that rob(o) or the robot being viewed, has a velocity of some huge number.
It only happens when rob(o) is fixed
The cause is that somewhere down the line, the accelerations are just being added to a fixed bot and velocity is not being reset.
Answer. Reset all .vx, .vy, .ax and .ay variables for all fixed bots on every cycle
If my previous fix didn't work I think it may have been because it wasn't resetting accelerations but was only resetting velocities. Accelerations are added to current velocities later in the program cycle so if accelerations continue to grow, then eventually we are going to add one that pushes velocity out of bounds.
That would explain how my previous fix allowed the program to run for longer before crashing since it wasn't compounding the error on each cycle.
Try this instead.
--- Code: ---If .mem(216) <> 0 Then
.Fixed = True
.vx = 0
.vy = 0
Else
.Fixed = False
End If
--- End code ---
and change it to
--- Code: ---If .mem(216) <> 0 Then
.Fixed = True
Else
.Fixed = False
End If
if .Fixed then
.vx = 0
.vy = 0
.ax = 0
.ay = 0
Endif
--- End code ---
Testlund:
Looks like we're not gonna find a solution any time soon, eh?
RUN-TIME ERROR 6: OVERFLOW
OFFENDING CODE:
:shoot: rob(n).mem(refvelup) = (rob(o).vx * Cos(rob(n).aim) + rob(o).vy * Sin(rob(n).aim) * -1) - rob(n).mem(velup)
HOVERING INFO:
rob(n).mem(refvelup) = 0
n = 794
refvelup = 699
rob(o).vx = 0
o = 800
rob(n).aim = 5,91204
rob(o).vy = 210549,3
rob(n).mem(velup) = 7980
velup = 200
I added a picture to show how the simulation looked like when it crash. maybe it whould give someone a hint, I don't know.
Testlund:
Well, it's any of those codes in that routine, choices at random. I'm quite sure it's the pond mode that is causing it.
My suggestion is: either get rid of 'Pond mode' (whould be a little boring I think) or make it work!
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version