Network Game in Python

Ben Sizer kylotan at gmail.com
Wed Aug 2 09:55:26 EDT 2006


diffuser78 at gmail.com wrote:
> Some questions I have are:
> 1. How can I manage network messages among the players. Should
> multicast be used or Actor should send the message to Supervisor and he
> sends to all. ?

Send a message from one client to the supervisor, handle it, then get
the supervisor to send messages back out to notify all clients of the
change. That way, the supervisor always has the correct state, and
knows which clients are aware of it.

> What python modules can be handy in these things.

The socket and select modules are all that you need. Perhaps there's a
higher-level solution somewhere but I don't expect you'd need it.

> 2. How can I manage moves among players. What move a player makes is
> visible to all others in real time, so essentially all players have the
> same consistent view of the game. Only the person with access can
> actually make a move or carry out action. Any suggestion how to carry
> out this thing.

As above: inform the supervisor/server of the move, and the server
informs all others of what is going on. Usually this is just a message
telling the client to update certain values. The client will update
those values and refresh the display. You may find it easiest to send
whole objects using pickle or something like that.

> 3. Shold I use a flat file or some database in mySQL to measure points
> etc ? I want to have a repository which keep tracks of all the mvoes in
> the system and who played what move etc..? Any suggestions on this.

Use whichever is easiest for you. Why do you need to save the data to
disk anyway? If you definitely need to do that, the shelve module is
often a good choice for basic needs. But it depends on what you need to
do with the information after you write it. 

-- 
Ben Sizer




More information about the Python-list mailing list