tic-tac-toe-js

0.0.2 • Public • Published

Tic Tac Toe

JavaScript tic tac toe game.

Usage

npm install tic-tac-toe-js

$ node

> var Game = require('tic-tac-toe-js').Game;
[Function Game]
> game = new Game;
{ xScore: 0, oScore: 0, winner: null }
> game.move('x', 1);
true
> game.move('o', 9);
true
> game.isFinished();
false
> console.log(game.toString());
X |   |
--+---+--
  |   |
--+---+--
  |   | O
> game.move('x', 4);
true
> game.move('o', 7);
true
> game.move('x', 4);
true
> console.log(game.toString());
X | X | O
--+---+--
X |   |
--+---+--
O |   | O
> game.move('x', 6);
true
> game.move('o', 8);
true
> console.log(game.toString());
X | X | O
--+---+--
X |   | X
--+---+--
O | O | O
> game.move('x', 5);
false
> game.isFinished()
true
> game.winnner
'O'

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.2
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.2
    0

Package Sidebar

Install

npm i tic-tac-toe-js

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • benjreinhart