OO and game design questions

Carl Banks pavlovevidence at gmail.com
Tue Oct 19 20:08:28 CEST 2010

On Oct 19, 1:19 am, dex <josipmisko... at gmail.com> wrote:
> > I'm not sure if it's a good idea to let an item disappear from your
> > inventory by a weak reference disappearing.  It seems a little shaky
> > to not know where your objects are being referenced, but that's yout
> > decision.
> OK, imagine a MUD, where players can "dig out" new rooms. Room A has a
> door that holds reference to newly created room B. By "using" a door,
> player is transported to room B. At later time someone destroys room
> B.
> Using strong references, I have to remove room B from list of rooms,
> and also remove door to room B, as it holds reference to room B. To do
> that, I have to keep list of doors that lead to room B.
> Using weak references, I don't have to worry about removing all doors
> to room B. They all now have a dead reference, which better models
> actual situation. If part of mine collapses, or if a module on space
> station is destroyed, the passage to that location does not magically
> vanish - it's just obstructed.
> Can you please tell me if there's something wrong with my reasoning?

Well, you're talking about particulars here whereas I am speaking in
general.  If something is "questionable" or even "bad" in general it
doesn't mean there are no particular cases for it.

Generally speaking: in a game there's presumably some conservation of
objects.  If you drop an item, does it disappear, or does it become an
object of the room?  Weak referencing won't help you in the latter
case because you have to take care of references at both ends anyway.
That's what I mean by shaky: it lets you forget about half of the
transaction, which might not be the best thing.  YMMV

Carl Banks

More information about the Python-list mailing list