2.1.2 • Published 6 years ago

smart-tictactoe v2.1.2

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

Smart TicTacToe:

What does it do?

Smart TicTacToe adds a function to your Node.js app that returns the best move possible for the computer in a TicTacToe game. It is impossible to loose with this algorithm.

Methods:

bestMove(<gameBoard (type is a string with a length of 9 characters)> : Returns the position that has the highest chance of winning (See figures under ## Examples)Note: Computer is always O support to change has not yet been released.

conversionTest(<String to test>) : For testing purposes only.

Examples:

Smart TictacToe is really simple to use:

var tictactoe = require('smart-tictactoe');<br>
console.log(tictactoe.bestMove(o   xxo x);<br>

This logs 4 in the console because tictactoe.bestMove() returns the best location for the computer if the scenario was:

O__
_XX
O_X

Which is 3 to prevent X from winning because the TicTacToe board is stored as a array: 0 | 1 | 2 -----|-----|----- 3 |4|5 6|7|8

What's New in this Update:

  • Added method: conversionTest();
  • Fixed bugs
  • Made code more efficient
  • Added a simple argument checker to prevent invalid input: returns "undefined" if invalid arguments.

Installation:

You can install Smart-TicTacToe like any other npm module:

npm install smart-tictactoe

Smart-TicTacToe does not require any external dependencies.

License:

Copyright (c) 2018 Luke Chu [lukechu10@gmail.com](mailto:lukechu10@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

2.2.0-pre.2

6 years ago

2.2.0-pre.1

6 years ago

2.2.0-pre.0

6 years ago

2.2.0-beta.6

6 years ago

2.2.0-beta.5

6 years ago

2.2.0-beta.4

6 years ago

2.2.0-beta.3

6 years ago

2.2.0-beta.2

6 years ago

2.2.0-beta.1

6 years ago

2.2.0-beta.0

6 years ago

2.2.0-alpha.2

6 years ago

2.2.0-alpha.1

6 years ago

2.2.0-alpha.0

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

2.0.0-alpha.1

6 years ago

2.0.0-alpha.0

6 years ago

2.0.0-0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.1.0-0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago