Skip to content

benrandja-akram/unbeatable-tic-tac-toe

Repository files navigation

Unbeatable Tic-Tac-Toe using MINIMAX algorithm

How it works

Minimax Tree

The algorithm must find a move that leads to the greatest chance of victory or at least a draw.

Each level of the tree switches back and forth between MAX levels (where the objective is to help the computer player by maximizing the score) and MIN levels (where the objective is to help the adversary by minimizing the score).

Given a specific game state, function score(board) is evaluation function that returns an integer representing the score of the game from the player’s perspective.

function score(board: Board): -1 | 0 | 1 {
	const winner =...

	if(winner === 'player') return -1
	if(winner === 'computer') return 1

	// draw or game is not yet finished.
	return 0
}

References

About

Unbeatable Tic-Tac-Toe game using MiniMax algorithm.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published