tic-tac-toe-playing-algorithms
v1.0.3
Published
Algorithms for playing a 3x3 Tic Tac Toe Game
Downloads
2
Readme
Tic Tac Toe Playing Algorithms
An implementation of various algorithms for playing a 3x3 tic tac toe game.
The algorithms includes:
- Minimax
Usage
ES5:
var minimax = require ('tic-tac-toe-playing-algorithms').minimax;
var myPlayer = 'X';
var otherPlayer = 'O';
var currentPlayer = myPlayer;
var board = [
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]
];
var nextMove = minimax(board, currentPlayer, myPlayer, otherPlayer);
console.log(nextMove);
ES6:
import { minimax } from 'tic-tac-toe-playing-algorithms';
const myPlayer = 'X';
const otherPlayer = 'O';
const currentPlayer = myPlayer;
const board = [
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]
];
const nextMove = minimax(board, currentPlayer, myPlayer, otherPlayer);
console.log(nextMove);