Hi Stuart,

There is a bug in end-game? which means it never ends.  I'm not sure if this
is the most idiomatic way to fix it but it seems to work.

< (defn end-game? [{:keys [apple snake]}]
<   (cond
<     (lose? snake) (do (reset-game) "You lose!")
<     (win? snake) (do (reset-game) "You win!")))
---
> (defn end-game? [game]
>   (let [{:keys [apple snake]} game]
>     (cond
>       (lose? @snake) (do (reset-game game) "You lose!")
>       (win? @snake) (do (reset-game game) "You win!"))))

Cheers

Tom

(I include a version which won't run off the edge, enjoy)

2009/1/6 Stuart Halloway <stuart.hallo...@gmail.com>

>
> Hi Rich,
>
> Thanks for the suggestion. I have moved all the per-game stuff (apple,
> snake, frame, panel, and timer) into a local let inside a game
> function. Is that what you had in mind?
>
> Stuart
>
> > On Jan 6, 11:54 am, Stuart Halloway <stuart.hallo...@gmail.com> wrote:
> >>> Code like @*foo* is not something I've seen in any code Rich has
> >>> written, so I think Stuart is right in considering removing the
> >>> asterisks on *apple* and *snake*
> >>
> >> I plan to remove them. What I still wrestle with is using "snake" at
> >> the top level as ref, and then having a bunch of pure functions that
> >> shadow the top level snake with a binding to an immutable snake data
> >> structure.
> >>
> >
> > Might I suggest then that you do away with the globals snake and apple
> > altogether?
> >
> > The result will be a much cleaner program.
> >
> > Rich
> >
> > >
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Attachment: my-stu-snake.clj
Description: Binary data

Reply via email to