You might want to put it into a loop, keeping the 'played' values as the
loop bindings. (I imagine [false false] in my head, but whatever is
meaningful to you.)

If the timer dings, you evaluate the winner.

If you get a value on a player channel and the other player HAS played, you
might recur with a new timeout channel and empty 'played' values. Thus the
game starts over. (Careful - you don't want to accumulate a bunch of
timeout channels. I haven't looked into this deeply.)

If you get a value on a player channel and the other player HAS NOT played,
you recur with the existing timeout channel and an updated copy of the
'played' values (in my head, [true false] or [false true]).

Chris

On Sat, Jan 10, 2015 at 11:53 AM, Jeremy Vuillermet <
jeremy.vuiller...@gmail.com> wrote:

> Hi,
>
> I'm learning core.async with a game I'm developing.
> This is a one on one game where players have 5 seconds to play. If only
> one has played before 5 seconds, he is the winner. If none has played, I
> randomly choose a winner.
>
> I have 3 channels, player1-channel, player2-channel and timeout-channel.
> Although I know I can use alts! to detect the timeout like
> (alts! [player1-channel player2-channel timeout-channel])
>
> I won't be able to detect the case when only 1 player has played.
>
> I can't think of a proper way to do this. Any idea ?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to