Code center > Bug reports
Found Bug Need Stablest Vers 2.37.4
Numsgil:
No, I'll try to make it stable, because I need a stable platform to compare the C++ to when it's finished.
I just won't work on bugs that don't crash the sim ;)
Endy:
Well it can crash the sim, most of the time though alhiemizers death kicks in and kills the tied bot. One of us can probably do the changes. Can you tell me basically how the code needs moded?
Numsgil:
There are a couple errors there. For instance, th 2nd line If .mem(tp + 3) > .Waste Then .mem(tp + 3) = .Waste should probably come after that third line.
Feel free to play with it Endy, my mind is still a little groggy from the Six flags trip (Up at 6 AM, back at 1 AM) and I can feel it slipping even as I type... lol
PurpleYouko:
I don't see any problem with this code. :blink:
Either you are reading it wrong or I am.
Let's try going through it in detail to see who is right.
first bit.
--- Code: --- If .mem(tp + 2) = -4 And .mem(tp + 3) <> 0 Then 'trade waste via ties
If .mem(tp + 3) > 1000 Then .mem(tp + 3) = 1000
If .mem(tp + 3) > .Waste Then .mem(tp + 3) = .Waste
If .mem(tp + 3) < -1000 Then .mem(tp + 3) = -1000
--- End code ---
.mem(tp+2) is the type of transaction. A value of -4 denotes waste transfer.
.mem(tp+3) is the value in .tieval
Line 1 checks that the transaction type is "waste" and that the transfer ammount is NOT zero.
Line 2 ensures that no positive value of greater than 1000 is transfered (given away)
line 3 ensures that no positive value greater than the giving robot's current .waste, can be transferred. (given away)
line 4 ensures that no negative value with magnitude greater than 1000 can be transferred (taken)
Don't see any problems here.
It may look as if it is possible to steal waste from another bot in excess of the ammount of waste that it has but this is checked later before actual transfer takes place. It was easier to write the code that way.
The next bit (in more detail)
--- Code: ---If .mem(tp + 3) > 0 Then
rob(.Ties(k).pnt).Waste = rob(.Ties(k).pnt).Waste + .mem(tp + 3)
.Waste = .Waste - .mem(tp + 3)
.Pwaste = .Pwaste + (.mem(tp + 3) / 1000)
Else
If rob(.Ties(k).pnt).Waste > Abs(.mem(tp + 3)) Then
rob(.Ties(k).pnt).Waste = rob(.Ties(k).pnt).Waste + .mem(tp + 3)
.Waste = .Waste - .mem(tp + 3) 'robot steals waste from tied target
rob(.Ties(k).pnt).Pwaste = rob(.Ties(k).pnt).Pwaste - .mem(tp + 3) / 10
Else
.Waste = .Waste + rob(.Ties(k).pnt).Waste
rob(.Ties(k).pnt).Pwaste = rob(.Ties(k).pnt).Pwaste + rob(.Ties(k).pnt).Waste / 10
rob(.Ties(k).pnt).Waste = 0
End If
rob(.Ties(k).pnt).Pwaste = rob(.Ties(k).pnt).Pwaste - .mem(tp + 3)
End If
--- End code ---
The line that you refer to.
--- Code: ---rob(.Ties(k).pnt).Pwaste = rob(.Ties(k).pnt).Pwaste - .mem(tp + 3)
--- End code ---
is inside the ELSE condition of the outer conditional. I.e .mem(tp+3) must be negative in order to ever reach this line of code.
What this code will do is to subtract the value of .mem(tp+3) from the pwaste of the robot on the other end of the tie.
Since .mem(tp+3) must be negative, this will add its value to the pwaste of the tied robot.
I think I begin to see the problem
There is a complete screw up here since the ammount of pwaste added is an order of magnitude too high, and the code is in the wrong place so that no checks are made to see if the tied robot actually had the waste to start with.
The fix for this would appear to to change the last section of the code as follows.
--- Code: ---If .mem(tp + 3) > 0 Then
rob(.Ties(k).pnt).Waste = rob(.Ties(k).pnt).Waste + .mem(tp + 3)
.Waste = .Waste - .mem(tp + 3)
.Pwaste = .Pwaste + (.mem(tp + 3) / 1000)
Else
If rob(.Ties(k).pnt).Waste > Abs(.mem(tp + 3)) Then
rob(.Ties(k).pnt).Waste = rob(.Ties(k).pnt).Waste + .mem(tp + 3)
.Waste = .Waste - .mem(tp + 3) 'robot steals waste from tied target
rob(.Ties(k).pnt).Pwaste = rob(.Ties(k).pnt).Pwaste - .mem(tp + 3) / 10
Else
.Waste = .Waste + rob(.Ties(k).pnt).Waste
rob(.Ties(k).pnt).Pwaste = rob(.Ties(k).pnt).Pwaste + rob(.Ties(k).pnt).Waste / 10
rob(.Ties(k).pnt).Waste = 0
rob(.Ties(k).pnt).Pwaste = rob(.Ties(k).pnt).Pwaste - .mem(tp + 3) / 10
End If
End If
--- End code ---
Just need to move the line of code inside the inner ELSE conditional.
Navigation
[0] Message Index
[*] Previous page
Go to full version