1.0.3 • Published 6 years ago

tic-tac-toe-playing-algorithms v1.0.3

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

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);
1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago