tic-tac-toe-helper
v1.0.3
Published
finding the optimal move in the game Tic-Tac-Toe
Readme
Tic-Tac-Toe-helper
Library for finding the optimal move in the game "Tic-Tac-Toe" by Alesia Luzko
Description
This function tries to find the best move and tries to prevent the opponent from making a winning move.
Installation
npm install tic-tac-toe-helper --saveUsage
import { bestMove } from 'tic-tac-toe-helper';
const board = ['X', 'O', null, 'X', null, null, 'O', 'O', 'X'];
const player = 'X';
bestMove(board, player); // return '4'