Dear all,
I am writing a small application for a project in Experimental
Economics.
For those who do not know what this is: experimental economics uses
controlled, computerised lab experiments with real subjects, putting
the subject in a game mimicking the situation of interest and
collecting behavioural data about choices made.
Hence, experiments involve the use of a multi-client architecture with
one server, and are sort of online games, with actions taken by
clients - each sitting on a different PC - and computation, data
collection, etc... handled by servers.
My game is a sort of Scrabble, with palyers buying letters and
producing words or extending existing words. I use a pipe to ispell -a
for spellcheck, XMLRPC for the server-client infrastructure, and have
developed all the rules of the game as server functions, called by the
clients, that play in turn. States of players and of words created are
stored in instances of two basic classes, Player and Word, on the
server side.
The command line interface works on a turn-base: clients keep asking
the server whether it is their turn or not, and wait in the meantime,
just receiving updates on the 'board' on other players' actions. When
its turn comes, client i performs its operations (buying letters,
composing words) and then passes to the next player.
I need to know how changes on one client's GUI (eg: update game
status; eg: show waiting screen) can be triggered by remote events,
i.e. by events generated on other clients, and then acknowledged by
the server.
In the CLI this is done this way:
---client code---
while True:
Active = server.checkstatus(i)
while Active == 0: #player not
active - keep checking and wait
Active = server.checkstatus(i)
otheraction = server.checkaction() #keep checking for
actions by other players
if otheraction == True:
print details of otheraction
refresh state of the game (players, words)
if Active == 1: #player's
turn starts
buy letters
produce words
pass
print 'Your turn is over: passing the turn to the following
player...'
notify server of ownaction
server.passturn() #tell the
server to send Active to next player.
···
----------------------
What I need is a way of triggering a local GUI event - i.e. 'refresh
statistics' and the like, which triggers the refreshing of the main
window and/or on the popping up of dialogs - from a remote event on
the server. The basic GUI is only updated in case of gathering
statistics - imagine a control deck of a vehicle - but a new dialog
has to pop up when the player's turn comes and he has to make
decisions.
Does anyone have any hints on how to deal with this?
Thanks,
Paolo Crosetto
--------------------------------------------------------------------------------
PhD Student in Economics
DEAS - Department of Economics - University of Milan
--------------------------------------------------------------------------------