0.3.1 • Published 5 years ago

thaw-tic-tac-toe-engine v0.3.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

thaw-tic-tac-toe-engine

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

Build Status npm npm license Maintainability Known Vulnerabilities

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 and unit 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'
}

License

MIT