An unbeatable but quite user friendly and addictive game of Tic Tac Toe. This game was developed using React and Typescript. In the case of styling the app uses SCSS since it allows for cleaner code with nesting, variable usage which helps with keeping a theme like the colour theme in this case etc.
The game consists of a 3x3 board where the player and the computer interact.
Rules of the Game
- Player always gets the first turn
- Only empty spaces can be selected
- Board is disabled during computer rounds
- The first player to place 3 marks in a vertical, horizontal, or diagonal row wins the game
- If all spaces are filled, and there is no winner, the game ends in a tie
- At any point in the game the board can be reset by clicking the 'Reset' button
Prerequisites
- Node v18.x or higher (latest version is best)
Run npm i to install all the dependencies
Development
- Next run
npm startto get the application running - Open http://localhost:3000 to view it in the browser. (Note: If that port is already taken up it will run on the next available port)
Testing
- Next run
npm testto get tests started - All the existing tests should run in the terminal
Note:
- The app uses the npm package tic-tac-toe-ai-engine to generate the computer movements
- Winner is calculated through the helper function checkWinner()
- All logic is separated into components and included in the
componentsfolder - Tests are included in the components folder as well under the subfolder
__test__ - Common files including the
type.tsandconstants.tsare included in thecommonfolder - All helper functions can be found in the
helpersfolder
Have a feel of the game for yourself, Demo