Skip to content

Implementation of Tic tac toe game using mini-max algorithm and alpha-beta pruning with JavaFX

Notifications You must be signed in to change notification settings

parham1998/Tictactoe_mini-max

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tictactoe_mini-max (warm-up project!)

Implementation of the Tic tac toe game using mini-max algorithm and alpha-beta pruning with JavaFX

There are 2 java files in src/tictactoe. actually mini-max algorithm with alpha-beta pruning implemented in board.java. you play as X and the computer plays as O, in fact, after your turn, the computer will consider all possible scenarios and makes the most optimal move.

mini-max algorithm and alpha-beta pruning

mini-max algorithm tries to find the best move in every step by evaluates all the available moves. (see image below)

alpha-Beta pruning is not actually a new algorithm, rather an optimization technique for minimax algorithm.
It reduces the computation time by a huge factor. This allows us to search much faster and even go into deeper levels in the game tree.
It cuts off branches in the game tree which need not be searched because there already exists a better move available.
It is called Alpha-Beta pruning because it passes 2 extra parameters in the minimax function, namely alpha and beta.

Alpha is the best value that the maximizer currently can guarantee at that level or above.
Beta is the best value that the minimizer currently can guarantee at that level or above.

mini-max

implementation details

I considered two modes, easy and hard! (to make the game easy, I reduced the depth of the mini-max tree to 1, and in the hard scenario, considered all possible depths of the mini-max tree)

the following animation shows the performance of the mini-max algorithm in the tic tac toe game:

tic-tac-toe

About

Implementation of Tic tac toe game using mini-max algorithm and alpha-beta pruning with JavaFX

Topics

Resources

Stars

Watchers

Forks

Languages