[Twisted-Python] Thinking backwards, design ideas
santacruz at southern.edu
Sat Apr 19 22:46:59 EDT 2003
I have finally read all that seemed necesary to get a good feel of
twisted! and I have finally been able to implement a few 'play'
I have a project I'd like to write, and I have always tought about it in
the normal "use a library" fashion (in oppisition to the "use a
framework"). My idea is to create a program that is a tournament
manager, it works kind of like this:
* Accepts connections (there are 2 types, admin, regular).
* Listen to the admin connection
- Start tournament at admin's command
This would create tournament brackets and actually give the
connected players the "play" command.
- View current games
- A bunch of other things :)
Then when the admin starts the games, the program would spun a new "game
thread" that would have the game logic, and that would keep track of the
game (check legality of moves), tell player A to go, tell B what A play,
tell B to go, decide on the winner, etc.
But now I find my self trying to think twisted. I am no longer in
control of the main program loop it seems. I see how I can keep some of
my static info (having my Protocols register them in the Application).
What I'm having a hard time with is envisioning how to get my games
started, and how to keep track of them.
* Where does my game-logic go?
* Do my protocols check for valid moves... if so, who keeps track of the
board? The board is a share resource between 2 players of a short
amount of time, and there are potentially many games going on at the
* How can I implement timeouts? So that players have to play within
given time-limits? (like, X seconds per-move kinds of deals?) I
thougt about starting a timer in my Protocol when a "MAKE A MOVE"
command is sent to the player, and then checking that time when the
move is received... but this seems to involve threads?
Anyway, I'd really would appreciate your thoughts on this. This
'higher-design' stuff is keeping me from getting dirty :)
More information about the Twisted-Python