Assumption
Users wanting to play this game have prior knowledge of git, the console and node.js and have all installed on their operating system.
For more information on getting started with git, please see here:
Getting started with Git and GitHub: the complete beginner’s guide.
For more information on navigating the command line (also known as the terminal and console) please see here:
Mac - A Beginner's Guide to Using the Mac Terminal
Windows - A Beginner's Guide To The Windows Command Line
For more information on Node.js please see here:
-
Press
⌘ + spacebar
. This will initiate the spotlight search. -
Input
terminal
and click on the terminal program which is returned as thetop hit
-
Once in the terminal application type
git clone https://github.com/bennnym/FMA_TicTacToe.git
and press↩
. This clones the tic-tac-toe repository onto the user's computer. -
Now enter into the terminal
cd FMA_TicTacToe
and press↩
. This navigates into the newly created folder. -
We now need to install the required packages to run the game. In the terminal enter
npm install
and press↩
. -
Now enter
npm run game
and press↩
and enjoy the game!
-
Press
❖
(windows key) or❖ + R
and type incmd
. -
In the
command prompt
typegit clone https://github.com/bennnym/FMA_TicTacToe.git
and press↩
. -
Open the
command prompt
program and navigate into the newly created folder by typingcd FMA_TicTacToe
and hitting↩
. -
Enter
npm install
and press↩
. -
Now enter
npm run game
and press↩
and enjoy the game!
-
The game is played on a grid that is 3 x 3 squares.
-
Two players are required for a game.
-
Player 1 always starts the game and assumes the marker "X".
-
Players take turns to play until a player wins, or the end of the game (whichever happens first).
-
The first player to get three of their markers in a row (vertically, horizontally or diagonally) is the winner.
-
If all 9 squares are full and no player has won, the game ends in a draw.
-
To input a marker the player must enter the
x
andy
coordinates of the position they wish to place the marker. Like so:
1,1 | 1,2 | 1,3
---------------
2,1 | 2,2 | 2,3
---------------
3,1 | 3,2 | 3,3
-
The solution to the tic-tac-toe problem was purposefully executed with clear variable and function names. There was a deliberate effort to make the code as readable as possible.
-
Individual functions were written for all actions required within the game play. Such as placing a marker, checking if there is a winner or a draw, checking if the space is available, clearing the board, displaying the board and validating user input.
-
All of these functions are tied in together with the use of the
inquirer
node package in order to receive user input from the console. -
The combination of the welcomeMessage, playGame and playAgain functions navigate a tic-tac-toe game in a somewhat recursive solution where the players have power over how long the game runs according to their input. If the player decides to continue playing, the game continues and if the player decides to give up or finish playing the code exits and the game is over.