Skip to content

Latest commit

 

History

History
44 lines (35 loc) · 3.62 KB

README.md

File metadata and controls

44 lines (35 loc) · 3.62 KB

Othello-Pygame-AI-Project

Artificial Intelligence (AI) final project #01 - Summer 2024

Project summary

||| In the name of Allah |||
---------------------------
Implementation of a digital Othello game using minimax (alpha-beta pruning) algorithm and Pygame library.
All functions and variables are written in a Python file Othello - Execute.py; run it to play.
Read the guides and explanations of this projcet in the Othello - Review.pdf file.

Minimax algorithm

Minimax is a backtracking algorithm used in decision-making and game theory to determine the best move for a player, provided that your opponent also plays optimally. It is commonly employed in two-player turn-based games like Tic-Tac-Toe, Backgammon, Mancala, Chess and etc.
In Minimax the two players are called maximizer and minimizer. The maximizer tries to get the highest score possible while the minimizer tries to do the opposite and get the lowest score possible (zero-sum).
For eaxmple in a board game (zero-sum game), every board state has a value associated with it. In a given state if the maximizer has upper hand then, the score of the board will tend to be some positive value. If the minimizer has the upper hand in that board state then it will tend to be some negative value. The values of the board are calculated by some heuristics which are unique for every type of game.

More guides and explanations:

Minimax tree example

Minimax-tree

Alpha-Beta Pruning algorithm

Alpha-Beta pruning is not actually a new algorithm, but rather an optimization technique for the 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.

Let’s define the parameters alpha and beta with the pruning condition:

  • Alpha: the best value that the maximizer currently can guarantee at that level or above.
  • Beta: the best value that the minimizer currently can guarantee at that level or below.
  • Pruning: for each node, if beta ≤ alpha, subtree of this node is pruned.

See the links below:

Game user interfaces

1- Welcome menu and Game board 3- Win and Lose menu