Strange Behavior of the game.creeps list

Bug #188395 reported by simpsus
4
Affects Status Importance Assigned to Milestone
pyTD
Fix Released
Undecided
Unassigned

Bug Description

When a creep is dying, and the Game class tries to remove it from the "creeps" list via:

self.creeps.remove(creep)

it is not found in the list and an exception is thrown.
However the creep is of course in the list and this code does the job

for c in self.creeps:
    if c.id == creep.id:
        self.creeps.remove(c)

there seems to be an issue with how the remove function compares the creeps, especially because

c == creep

in the body of the if above is True....

simpsus (bastian-kennel)
Changed in pytd:
status: New → Confirmed
Revision history for this message
KevinL (darius-obsidian) wrote :

I couldn't actually replicate this behaviour, so I've switched the code back - if you do get it again, do the following:

* In the first line of the method, put "import pdb ; pdb.set_trace()"

* When the trace starts, run the following commands:

  - print creep, id(creep)
  - print self.creeps, [ id(c) for c in self.creeps ]
  - print creep in self.creeps

Chuck the output of those onto this ticket, we'll have a closer look. If you haven't used pdb before, it's a worthwhile tool to get used to - helps a lot ;) Just never check a pdb statement in, it confuses the end users...

Revision history for this message
simpsus (bastian-kennel) wrote :

Great...
now it works again, without changing anything, without even pulling from bzr or anything alike...
anyway, here is the (expected) output:

(Pdb) print creep, id(creep)
<Basic Creep at (370.0, 36.0)> 140778828
(Pdb) print self.creeps, [ id(c) for c in self.creeps ]
[<Basic Creep at (370.0, 36.0)>] [140778828]
(Pdb) print creep in self.creeps
True

Thanks!!

KevinL (darius-obsidian)
Changed in pytd:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.