Skip to content

chokonaira/tictactoe-random

Repository files navigation

Tic Tac Toe Random

A Tic Tac Toe Random Algorithm NPM module in typescript to find random index of a given board

Node.js CI

NPM Package

NPM Random

Installation

Random Module

npm install tictactoe-random --save

npm install tictactoe-board --save

Usage

import Random from 'tictactoe-random'

import Board from 'tictactoe-board'

Intialize an instance object of the Random and 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 = ['', '', '', '', '', '', '', '', '']

Method

random.findRandomMove(board)

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 

About

A Tic Tac Toe Random Algorithm NPM module in typescript to find index on a given board

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published