Author Topic: Found Bug Need Stablest Vers 2.37.4  (Read 4144 times)

Offline Endy

  • Bot Overlord
  • ****
  • Posts: 852
    • View Profile
Found Bug Need Stablest Vers 2.37.4
« on: October 28, 2005, 04:07:34 AM »
Thread moved to bug reports

Think I tracked down the waste bug and presumably the venom bug is similar.
Fortunatly the vers are relativly the same in this area.

In the Ties section dealing with waste theft it talks about adding to pwaste the value of waste stolen, but doesn't check that said waste could in fact be taken.

Now I just need a version's source code to update properly. :)

I'll be at work all tomorrow, so I'll write sometime during the weekend.(please remember I'm about 6 hours back from you guys)
« Last Edit: October 28, 2005, 09:42:03 AM by PurpleYouko »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Found Bug Need Stablest Vers 2.37.4
« Reply #1 on: October 28, 2005, 09:03:25 AM »
I actually saw thius bug while I was porting the code, so it's in the VB version of 2.4 as well.

Fixed it for C++ source.

Not terribly huge, but definately a problem none the less.

Offline Endy

  • Bot Overlord
  • ****
  • Posts: 852
    • View Profile
Found Bug Need Stablest Vers 2.37.4
« Reply #2 on: October 30, 2005, 09:27:51 PM »
Code: [Select]
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
          k = 1
 ...
                End If
                rob(.Ties(k).pnt).Pwaste = rob(.Ties(k).pnt).Pwaste - .mem(tp + 3)
              End If

Is it that second line and the last line with Pwaste? The second line looks like it was letting in the negative tieval and the last adding that whole value to pwaste.

To fix it would you simply abs the tieval before checking > waste? That's what looks like what happened for venom.

Kind of sad it'll be gone, I messed around and was able to use it as a super defense against TF's. Made leaching look so passe.
« Last Edit: October 30, 2005, 09:29:26 PM by Endy »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Found Bug Need Stablest Vers 2.37.4
« Reply #3 on: October 30, 2005, 10:11:15 PM »
I'll fix it for the C++ port, no terribly anxious to crack open VB for too long.  Feels sort of like putting cosmetics on a corpse, if you know what I mean ;)

Offline Griz

  • Bot Overlord
  • ****
  • Posts: 608
    • View Profile
Found Bug Need Stablest Vers 2.37.4
« Reply #4 on: October 30, 2005, 10:16:00 PM »
Quote
I'll fix it for the C++ port, no terribly anxious to crack open VB for too long.  Feels sort of like putting cosmetics on a corpse, if you know what I mean ;)
so ....
what .... ?
you going to stop on 2.4 vb now that I almost got it working too?
gggrrrrrrrrrrrrrr!
不知
~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
Found Bug Need Stablest Vers 2.37.4
« Reply #5 on: October 30, 2005, 10:44:47 PM »
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 ;)

Offline Endy

  • Bot Overlord
  • ****
  • Posts: 852
    • View Profile
Found Bug Need Stablest Vers 2.37.4
« Reply #6 on: October 30, 2005, 10:49:52 PM »
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?
« Last Edit: October 30, 2005, 10:53:13 PM by Endy »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Found Bug Need Stablest Vers 2.37.4
« Reply #7 on: October 30, 2005, 11:04:02 PM »
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

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
Found Bug Need Stablest Vers 2.37.4
« Reply #8 on: November 15, 2005, 11:15:10 AM »
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: [Select]
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
.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: [Select]
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
The line that you refer to.
Code: [Select]
rob(.Ties(k).pnt).Pwaste = rob(.Ties(k).pnt).Pwaste - .mem(tp + 3)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: [Select]
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

Just need to move the line of code inside the inner ELSE conditional.
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D