/t3

Primary LanguageJavaScriptMIT LicenseMIT

T3 - Tic-Tac-Toe

Tic-Tac-Toe game implemented using React

This project was created using the Create React App tool and uses StandardJS rules

Demo

Dependencies

To run this project the following environment is necessary:

  • Yarn
  • Node >= 8.0.0

Run the project

Install the package dependencies using yarn:

yarn

Then, to start a development server running the application:

yarn start

This will open a browser window to http://localhost:3000/

Winning condition algorithm

Each square in the board is represented by either a 0 (free space), a number 1 (player 1: X) or a number -1 (player 2: O)

When taking a turn, the sum of these values for the selected row and column is updated to be compared with the size of the board.

For example if the sum of a row is 3, it means that player 1 won by completing that row. Likewise if the sum was -3 then player 2 won that row.

Also both diagonals are sumed in such a manner.

This method uses n + n + 2 values to check if there is a winner.