Turn-based game - experimental economics

Paolo Crosetto paolo.crosetto at unimi.it
Sat Sep 5 11:38:44 EDT 2009


Dear Terry, 

thanks.
> 
> As I understand your description, the server and each client will be a
> separate process on a separate machine (once deployed), so threads do
> not seem applicable. (For development, you can use separate processes on
> one machine communicating through sockets just as if they were on
> multiple machines.) 

Exactly. And this is exactly how I do it now. I have a process for the server, 
and process for the client (I succeeded in having it working with one client). 
I use XMLRPC to setup the server and make calls from the client.

> As I understand select, it is for select *any*
> available client input, not just one in particular. I believe the
> standard solution is to define a 'turn token' and write the clients so
> that they only do 'turn' activities when and only when they have that
> token.

This is similar to what bouncynic suggested. I was thinking of having a status 
global variable in the server that register whose turn it is [eg a list of N 
zeroes for N players] and ask the client to read that variable and act only 
when their own element in the list turns to one, white otherwise.

Does this make sense?

> I presume you do not need to worry about players trying to cheat
> by rewriting the client.

No, not really :)

I have one more question, then:

how do I make the client stay alive during the waiting period? Let me explain 
with rubbish pseudocode. Right now the code for handling turns, with status 
held on alist on the server, would be:

client:

if server.getStatus[i]==1:
	...play all the actions in one's turn...
	server.changeStatus[i] #changes to zero the global status var
	server.passTurn #the last action for client i is to set to 1 the triggervar 
for client i+1

else:
	wait

Now, my question is: how do I implement 'wait' without making the client exit? 
With gui-based clients I guess it is done with mainloop() keeping the app 
alive until something closes it; how do I achieve that with stdout (bash) 
clients?

Sorry for the not-so-much related question, and thanks for your suggestions.
	
-- 
Paolo Crosetto
---------------------------------------------------------------------
PhD Student in Economics
DEAS - Department of Economics - University of Milan
---------------------------------------------------------------------



More information about the Python-list mailing list