This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-10
Channels
- # announcements (8)
- # aws-lambda (4)
- # babashka (60)
- # beginners (65)
- # braveandtrue (5)
- # chlorine-clover (3)
- # cider (10)
- # clj-kondo (2)
- # cljdoc (2)
- # cljfx (32)
- # cljsrn (5)
- # clojure (198)
- # clojure-berlin (10)
- # clojure-europe (22)
- # clojure-france (1)
- # clojure-losangeles (33)
- # clojure-nl (3)
- # clojure-norway (22)
- # clojure-uk (35)
- # clojurescript (12)
- # code-reviews (14)
- # core-typed (1)
- # cursive (56)
- # datomic (13)
- # depstar (7)
- # emacs (1)
- # events (1)
- # figwheel-main (3)
- # fulcro (30)
- # graphql (15)
- # helix (1)
- # jobs (5)
- # juxt (6)
- # kaocha (14)
- # klipse (2)
- # malli (12)
- # off-topic (88)
- # portal (4)
- # re-frame (3)
- # reagent (5)
- # shadow-cljs (6)
- # specter (6)
- # sql (73)
- # tools-deps (15)
- # windows (4)
Anyone willing to do a code review. Its about 130 lines of code. Ive just recently started learning clojure so im probably doing a lot of things not the right way.
True, I didnt want to copy and paste the whole thing here
https://github.com/SantoHerrera/clojuretictac Thanks man, I really appreciate it.
What are some ways to avoid atoms? I'm not sure how.
some thoughts in no particular order:
• clojure doesn't automatically apply tail recursion. I would explicitly use loop/recur for the game loop
• I would make exitGame?
a pure function and not have it actually shut down the VM
• rather than updating state in a function call, I would make the state transition as an explicit step in the game loop. also, I would make the next value of the game a pure function of the previous value + input. maybe something like
(loop [game (new-game)]
(print-board game)
(let [action (read-action)]
(if (exitGame? action)
(get-winner game)
(recur (update-game game action)))))
• get input should return a valid input and do nothing elseI would opt for something like what @U7RJTCH6J did in this case though.
Thanks guys, ill change what was mentioned.
@U015CTPB4HZ There is a nice example of tic-tac-toe with Clojure in this video http://practicalli.github.io/clojure/games/tictactoe-cli/ There is also another approach using ClojureScript and SVG graphics https://practicalli.github.io/clojurescript/reagent-projects/tic-tac-toe/index.html Hope you find these of interest.
Ive actually got it to pass state around, im just ironing out some bugs. Ill still take a look at yours to see how you did though.