tic-tac-toe-playing-algorithms

1.0.3 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i tic-tac-toe-playing-algorithms

Weekly Downloads

7

Version

1.0.3

License

MIT

Unpacked Size

5.13 kB

Total Files

5

Last publish

Collaborators

  • socret360