chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] State machine using call/cc


From: felix winkelmann
Subject: Re: [Chicken-users] State machine using call/cc
Date: Wed, 8 Dec 2004 13:52:13 +0100

On Wed, 8 Dec 2004 12:30:55 +0000, Joel Reymont <address@hidden> wrote:
> 
> 
> The state machine would internally retrieve the continuation of the
> current state and run ask the current state for the next state and the
> sexp. It seems that all states should share the same continuation
> although I might be mistaken here. Maybe each state should save its own
> continuation and the "current continuation" should be set to that of the
> next state when it's chosen by the current state.
> 
> Is my logic correct? Would this be a viable architecture?
> 

IMHO each player would have his/her own continuation, with it's
lexical context containing enough information to know about the
actual game in progress (like some local variable holding a record
representing the current game).
If you explicitly keep continuations for each possible game-state
(independent of the player), you might be better of using normal
procedure (tail-) calls (google for Shriram Krishnamurti's "The Swine
before Perl" talk to see some slides about it).
But (if I understand you correctly) it would be better to execute a
game in a normal "procedural" fashion (do this, then that, etc.) for
each player, with carefully placed calls (actually continuation-returns)
back into the main-loop (the dispatcher), saving the current state
of the game in the shape of a continuation in some global table.
On requests sent from the player/client, the appropriate continuation
would be looked up again and the game resumes, at the proper
state (for this player).

To see something that is (remotely) connected to this problem,
take a look at Chris Double's nice demonstration of continuations
based web-programming, which is somewhat related to what
you describe:

http://www.double.co.nz/scheme/modal-web-server.html

(well, it's a different beast altogether and uses threads, but the
essence - saving a suspended state in a continuation - is similar)


cheers,
felix




reply via email to

[Prev in Thread] Current Thread [Next in Thread]