[Twisted-Python] Transporting pb.Copyable classes?

Jasper Phillips jasper at peak.org
Tue Apr 20 22:09:32 EDT 2004

On Wed, 21 Apr 2004, Andrew Bennetts wrote:

> On Tue, Apr 20, 2004 at 05:48:00PM -0700, Jasper Phillips wrote:
> > 
> > That's certainly feasible, but then I have an extra unserialize step
> > cluttering my code as the classes passed have attributes I want to access.
> > In general I'm passing game state which exists naturally as code, and while
> > I could always serialize and unserialize it, why bother if I don't have to?
> That's odd, I would've expected game state to exist naturally as *data*, not
> code. :)

I don't think the distinction between code and data is necesarrily so
clear...  Basically my point was that I wasn't interested in something like
XML RPC, and would rather treat remotely passed objects as if they were
local to the extent possible.

Using `Terrain.moveCost` instead of `unserialize("Terrain").moveCost` seems
good to me.

> Perhaps you should elaborate more on how you're representing things?

Ok.  I'm perfectly happy to get a critique of my design out of this if I
can! ;-)  I'll try to keep it concise.

I have a dictionary of hexes keyed by their grid location.

map.cells = {(1,1):hexCellInstance, ...}

Each of these cells has a .terrain, which is a reference to a Terrain
subclass.  These have static data and methods, for use by various game
algorithms, e.g. how far can unit Foo move through Mountains.

On each turn a (filtered) version of this state is passed to game clients,
so that they can view it, validate their orders against it, etc.


PS I'm off to watch a movie, so won't be able to respond further until
later tonight.

More information about the Twisted-Python mailing list