npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

tictactoe_model

1.0.3 • Public • Published

Tic Tac Toe Model

Copyright (c) 2019 Seán D. Murray SEE MIT LICENSE FILE

A logical model playing the tic-tac-toe (naughts & crosses, Xs & Os) game.

Usage

const TicTacToe = require('tictactoe_model');
const ticTacToe = new TicTacToe();
 
// Get whoes turn it is.
ticTacToe.turn();
 
// Make a move.
ticTacToe.move(0, 0); // X played
ticTacToe.move(1, 0);// O played
ticTacToe.move(0, 1);// X played
 
ticTacToe.turn(); // returns O
 
// Is the game done?
ticTacToe.isDone(); // returns false.
 
ticTacToe.move(1, 1);// O played
ticTacToe.move(0, 2);// X played
ticTacToe.move(2, 2);// O played
 
// Get the value at this coordinate.
ticTacToe.value(2, 2);// returns O
 
ticTacToe.isDone(); // returns true.
 
// Retrrns who the winner is.
ticTacToe.winner(); // returns player O

install

npm i tictactoe_model

Downloadsweekly downloads

2

version

1.0.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability