A Tic Tac Toe Random Algorithm NPM module in typescript to find random index of a given board
npm install tictactoe-random --save
npm install tictactoe-board --save
import Random from 'tictactoe-random'
import Board from 'tictactoe-board'
const board = new Board();
const random = new Random(board);
You can pass in an optional
custom Array of Strings as parameter to the Board
Example:
board = new Board(['X', 'X', '', '', 'O', 'O', '', '', ''])
now board.grid = ['X', 'X', '', '', 'O', 'O', '', '', '']
instead of default grid = ['', '', '', '', '', '', '', '', '']
This returns a random index of the given board
Example sceenerio:
const baord = new Board();
random.findRandomMove(board) = random index
This means position on the board is a random index from the available board index's