[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Subtle Memory Bug
Bob Ippolito wrote:
It's probably not the uniqueness of ID numbers that's breaking his code,
it's the fact that he has two different generations in the same data
structure. That's simply not how you should do what he's trying to do.
So, maybe have a tribes_this_turn dictionary and a next_turn_tribes
dictionary, with tribes getting copied into the next only if they
haven't been flagged as "gone?" It'd be tricky because what if tribes A
and B merge one turn, and in the same turn C tries to interact with
them? I guess the tribe that A/B become wouldn't exist till next turn,
but then there's the possibility that C will attack and destroy A on the
same turn that A has been absorbed into B.
Re: ID numbers, I had set it up so that no new tribe gets an ID number
that's currently in use... but if I understand correctly:
-The current value of self.alltribes always reflects changes made to the
game world, but
-The current set of values currently being used in the loop ("for tribe
in self.alltribes.values():") isn't affected by those changes because
it's evaluated only when the loop starts.
Kris