npm

Don't miss out on this year's npm Pride t-shirt designs!Order your favorites here »

thaw-tic-tac-toe-engine

0.3.0 • Public • Published

thaw-tic-tac-toe-engine

A Node.js Tic-Tac-Toe game engine with alpha-beta pruning and a heuristic, packaged for npm.

Git installation instructions:

$ git clone https://github.com/tom-weatherhead/thaw-tic-tac-toe-engine.git
$ cd thaw-tic-tac-toe-engine
$ npm install -g grunt
$ npm install
$ grunt

npm Installation Instructions:

$ npm install [--save] thaw-tic-tac-toe-engine

Note: The command "grunt" runs lint, unit tests, and security tests.

Sample usage of the npm package:

let engine = require('thaw-tic-tac-toe-engine');

let boardString = 'X X   O  ';
let maxPly = 2;		// maxPly is the desired maximum depth of the best move search tree.

try {
	let result = engine.findBestMove(boardString, maxPly);

	console.log(result);
} catch (error) {
	console.error('engine.findBestMove() threw an exception:', error);
}

Output:

{ bestRow: 0,
  bestColumn: 1,
  bestMoveList: [ { row: 0, column: 1 } ],
  bestScore: 1,
  player: 'O' }

install

npm i thaw-tic-tac-toe-engine

Downloadsweekly downloads

4

version

0.3.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability