[Cuis] Solitaire updated for 2203

Juan Vuletich juan at jvuletich.org
Wed Mar 25 07:12:54 CDT 2015


Very nice work Ken!

You managed to do the animation and game logic, interleaved with normal 
World cycling, and without any need to mess with "private" Morphic 
internals. Impressive.

I'm not sure, but I have a feeling that making 'mainLoop' and 
'pilesLoop' into separate methods might make debugging a bit easier.

I also believe that once you leave the world of simple lineal sequencing 
of calls and returns, debugging will always get trickier, just as design 
and coding. At least, your code is entirely predictable and 
deterministic. I remember the non-deterministic signaling of events in 
Tweak, and how harder debugging was there, when you could not even 
repeat the UI steps, and expect code to run the same. The biggest value 
I see in this code of yours is that it well teach the rest of us how to 
do it, when we need to.

Thanks,
Juan Vuletich

On 3/21/2015 1:40 PM, Ken.Dickey wrote:
> I updated Solitaire to work with asynchronous animation. Solitaire used to use synchronous animation, which has been removed.
>
> The main problem to be solved is how to interleave animation with control logic.  For example, in auto-moving cards from columns to piles, one wishes to check each card column and if any card has been moved to a pile, check each column again.
>
> The style I used here, CPS (Continuation Passing Style), makes control flow explicit.  Instead of returning, the last thing code does is invoke a closure passed in which does "the next thing".  This lets an asynchronous animation, as its last step, "pick up where it left off", e.g. to continue looping through card columns, checking for legal moves.  [Note CardTable Class>>cpsOverColl:do:next: and class side examples].
>
> This is a style experiment.  I am not totally happy with this style as it can be painful to debug.  Perhaps we should re-introduce the Continuation Class to capture continuations directly.
>
> In any case, we have Solitaire working again with the current Cuis version.
>
> Enjoy!
> -KenD
>
> _______________________________________________
> Cuis mailing list
> Cuis at jvuletich.org
> http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
>





More information about the Cuis mailing list