This tic-tac-toe version was built with Vue 3 in Vite.
Note: This is an advanced version of Tic-tac-toe. This assignment was published in Greatfrontend platform.
Tic-tac-toe is a game for two players who take turns making space in a three-by-three grid with X or O. The player who succeeds in playing three of their marks in a horizontal, vertical, or diagonal row is the winner. Source: Wikipedia
Traditionally, tic-tac-toe uses a 3 x 3 grid. In this problem, an advanced version of a tic-tac-toe game is built where the grid has N x N cells on the board and needs M marks in a horizontal, vertical, or diagonal row to win. The following diagram shows an example game where N = {{ N }} and M = {{ M }}.
You can change these parameters by adding to the URL parameters ?N=4&M=3
where N >= M
. Try it!
Three player modes are supported:
- Single player mode (1P) where a human player plays against an AI player. For this mode there are two available selections where the user can select between minimax and negamax algorithms.
- Two players mode (2P) where two human players can play against other.
- Auto mode (Auto) where two AI players can play against other.
VSCode + Volar (and disable Vetur).
TypeScript cannot handle type information for .vue
imports by default, so we replace the tsc
CLI with vue-tsc
for type checking. In editors, we need Volar to make the TypeScript language service aware of .vue
types.
See Vite Configuration Reference.
npm install
npm run dev
npm run build
Run Unit Tests with Vitest
npm run test:unit
Lint with ESLint
npm run lint
node > 18+