Hi,

I browsed over it, a couple of things:

`defonce` is meant for code reloading:

(defonce live-games (ref {})))

Don't use `for` when you can use `map`:

(mapv (fn [i] {:char i :visible (not (valid-char i))}))

Strings can be treated as sequences:

(first (.toLowerCase (str char)))

Hope this helps

Sebastian

On Friday, April 10, 2015 at 11:35:33 AM UTC+2, Andrea Crotti wrote:
>
> I created a small project just for learning more Clojure and wanted some 
> feedback to improve it and learn some more. 
>
> The code is all here, and it's both a desktop app that can be run with 
> "lein run" or a web API that can be run with "lein ring server": 
>
>
> https://github.com/AndreaCrotti/hackthetower_clojurescript/tree/master/hangman
>  
>
> The game is basically this 
> http://en.wikipedia.org/wiki/Hangman_%28game%29 (without the fancy 
> graphics still) 
>
> This is the sample structure of a move right now: 
> {:attempts 0 
>  :seen #{} 
>  :struct [{:char \a :visible false} {:char \b :visible false} {:char 
> \c :visible false}]} 
>
> So every time someone makes a move it will add a new game position to 
> a list of game snapshots, for example: 
>
> {"long-game-id": [{:attempts 1 :seen ${\a} :struct [{...}]} {:attempts 
> 0 :seen #{} :struct [{...}]}]} 
>
> and so on and so forth. 
>
> This is the function that alters the reference for example 
>
> (defn set-secret 
>   "Set the secret for a given name" 
>   [game-id game-struct] 
>   (dosync 
>    (alter live-games 
>           (fn [d] (assoc d game-id (conj (get d game-id) game-struct)))))) 
>
> Any suggestions is welcome, I also had some troubles trying to 
> minimize the refs/atoms while at the same time avoiding passing too 
> many things around. 
>
> I think now the solution of using game-id to hide the implementation 
> detail in 
> https://github.com/AndreaCrotti/hackthetower_clojurescript/blob/master/hangman/src/hangman/secret.clj
>  
> is not too bad but open for better ideas. 
>
> Thanks a lot, and if anyone is interested in joining the project 
> please let me know. 
>
> PS. next things to do are some deployment nice stuff, graphics with 
> Quill and a UI with Clojurescript 
>

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