Can you create an AI for classic Tic-Tac-Toe?
The challenge is made with typescript and react
Install npm and then you can install yarn with npm:
npm install --global yarn
install the dependencies with
yarn install
and then run
yarn start
You are O (P2) and the challenge is to write an AI that can play a tie in tic-tac-toe Start with ai.tsx
the intial state of the board is filled with number from 1 to 9
1 2 3
4 5 6
7 8 9
First you need to name your bot by editing the line
export const PLAYER_NAME = "";
Then you need to implement the getNextMove function
export function getNextMove(board: string[][], round: number): gameMove {
const possibleMoves: gameMove[] = getPossibleMoves(board);
return possibleMove[0];
}
See helpper functions in GameUtil.tsx
Gets all the possible moves on the board
returns true, if player is winning
returns true if spot is open
isMovesLeft