Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

larapollehn/Tic-Tac-Toe-Engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Tic-Tac-Toe engine with bruteforce minimax. The algorithm is dead simple, look into the future and choose the best branch.

The library is delivered with no further dependency and is therefore light-weight.

Install

npm i @larrywho11/tic-tac-toe

API

import {Board, Player} from "@larrywho11/tic-tac-toe";

// Create new board where player 1 goes first
const board = new Board(Player.PLAYER_1);

// Player 1 takes the middle
board.nextMove(1, 1);

// Player 2 takes top left
board.nextMove(0, 0);

// Call minimax for help for the next move of player 1
console.log(board.nextBestMove(Player.PLAYER_1);

// Check for winner PLAYER_1, PLAYER_2, DRAWN, UNKNOWN
console.log(board.winner());

Author

Lara Pollehn [email protected]

License

MIT License - https://opensource.org/licenses/MIT

About

A Tic-Tac-Toe engine with bruteforce minimax

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published