ttt-board

1.0.4 • Public • Published

TTT Board

A simple TicTacToe package for NodeJS, uses an Object Matrix type implementation for the board. Automatically takes care of turns and the board, simply move, get outputs and check if it's finished

Installation

$ npm install ttt-board

Running the tests

$ npm run test-ttt

Getting started

Basically just set it up

const ttt = new TTTBoard();

ttt.move("A", "2") // This uses an ABC 123 system, ABC for rows and 123 for columns, to move simply place ttt.move("A", "2") for example, top center, automatically turns to uppercase if lowercase
ttt.AImove() //Really is just a random move but it's cool to call it AI

let boardConfig = ttt.outputBoard() //Returns the board in it's config format, basically an object matrix
let boardImage = ttt.displayBoard() //Returns the board in a PNG format, just an image of the board
let boardASCII = ttt.writeBoard() //Returns the board in ASCII format (as a string), so you can write it to console! 

ttt.isFinished() //Returns true if the match has finished, to avoid making any more moves
ttt.turn() //Returns X or O depending on who's turn it is. When winning, ttt.turn() will output the winning letter

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.41latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.41
1.0.30
1.0.21
1.0.10
1.0.00

Package Sidebar

Install

npm i ttt-board

Weekly Downloads

2

Version

1.0.4

License

MIT

Unpacked Size

4.87 kB

Total Files

4

Last publish

Collaborators

  • entropicblackhole