tic-tac-toe-ai-engine

1.0.9 • Public • Published

Build Status Build Status

tic-tac-toe-ai-engine

Stateless Tic Tac Toe engine. Given a position the engine will give next best move, winner given perfect play, and the number of moves left with perfect play.

Test in browser

Tic Tac Toe AI Engine in Runkit

Example:

var ticTacToeAiEngine = require("tic-tac-toe-ai-engine");
 
var gameState = ['X', '', '', 'O', '', '', 'X', 'O', ''];
console.log(ticTacToeAiEngine.computeMove(gameState));
 
/*
Output:
  { winner: 'X',
    depth: 3,
    nextBestGameState: [ 'X', '', 'X', 'O', '', '', 'X', 'O', '' ] }
*/

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.9
    5
    • latest

Version History

Package Sidebar

Install

npm i tic-tac-toe-ai-engine

Weekly Downloads

5

Version

1.0.9

License

MIT

Last publish

Collaborators

  • syscoder