-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ttt with a cli #2
base: main
Are you sure you want to change the base?
Conversation
This reverts commit f9b9f4e.
A general observation: add a bit more words to the commit messages. it is not just about adding or updating files or fns, it is about giving a brief but thorough description of the changes going into that commit. ex: this has some good ideas: https://initialcommit.com/blog/git-commit-messages-best-practices |
-- todo: fix tests -- todo: refactor some of the loops and extract more fns
@@ -0,0 +1,46 @@ | |||
# Tic Tac Toe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Try to think of the README as the first thing a potential user might be looking at. What would that person want to see here?
Some potential questions:
- What does this repo do?
- How do I set this up in my machine?
- How do I test this out?
- How to I play the game?
Thinking from this perspective will help pen down a more thoughtful README.
practice/ttt/board.clj
Outdated
|
||
(def valid-game-pieces-set #{:o :x :e}) | ||
|
||
(def game-pieces-set #{:o :x}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Should we consider :x
and :o
as players rather than pieces? Even the wiki thinks of it that way. What do you think?
(assoc-in board coordinate game-piece))) | ||
|
||
|
||
(defn winner-of-collection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: What does collection
refer to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the function can find the winner of any collection as opposed to a 3x3 board. Used the word collection to generalize
@@ -0,0 +1,30 @@ | |||
(ns ttt.user-input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion/question: What do you think about naming this layer cli
instead of user-input
? The functions here are very specific to parsing user input from the command line. We might have an entirely different set of validations for user input if we were to create a web UI interface for the game, and so this namespace might not entirely make sense at that point. It's a stretch of course (since we don't plan on building a web UI), but still something to think about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, the user-input namespace is never reading directly from the cli. This particular namespace has no idea that a cli exists, it's just parsing input that is not necessarily from the command line. Thats why I think naming it user-input works better.
practice/ttt/matrix_operations.clj
Outdated
(str | ||
(apply str "\n" | ||
(interpose " " row)))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: Using a thread last macro might make the section more readable:
(->> row
(interpose " ")
(apply str "\n")
str)))
Also, do we need to str
at the end if we're doing apply str
in the previous step?
Added Cli to tic tac toe.