Question

Write a Python Program to implement the Min-Max Algorithm.

08 Aug 2026
Answer :
Word Count : 1213
The Min-Max algorithm is one of the fundamental algorithms used in Artificial Intelligence, particularly in game-playing and decision-making systems. It is commonly applied to two-player, zero-sum games such as Tic-Tac-Toe, Chess, Checkers, and Connect Four. The basic idea of the algorithm is that one player tries to maximize the score or utility, while the other player tries to minimize it. Therefore, the two players are generally referred to as the MAX player and the MIN player. The Min-Max algorithm represents the possible moves of a game in the form of a game tree. Each node of the tree represents a particular game state, and each branch represents a possible move. The leaf nodes represent terminal states or states at which the search is stopped. A numerical utility value is assigned to these terminal states. The MAX player selects the move with the highest utility value, whereas the MIN player selects the move with the lowest utility value. By working backward from the terminal states to the current state, the algorithm determines the best possible move. The algorithm assumes that both players play optimally. MAX assumes that MIN will always choose the move that is worst for MAX, while MIN assumes that MAX will always choose the move that is best for MAX. Thus, the algorithm considers the opponent's best possible response before selecting a move. A simple Python implementation of the Min-Max algorithm is given below: ```python def minimax(depth, node_index, maximizing_player, values, height): # Base condition: if the leaf node is reached if depth == height: return values[node_index] if maximizing_player: return max( minimax(depth + 1, node_index * 2, False, values, height), minimax(depth + 1, node_index * 2 + 1, False, values, height) ) else: return min( minimax(depth + 1, node_index * 2, True, values, height), minimax(depth + 1, node_index * 2 + 1, True, values, height) ) # Terminal node values values = [3, 5, 2, 9, 12, 5, 23, 23] # Calculate the height of the binary
______ ___ ____ _______ ____ ____ _________ ___ _________.
__________ _______ ________ ___ __________ _______.
____ __________ _______ _____ ___ ________ _____ ______.
______ __________ _________ _________ ______ _______ _____ ____ ____.
_____ _____ ______ _________ ____ _____.
__________ _________ ______ _____ _______ _______ _____ _______ ___ _________ _________.
__________ ________ _________ _________ __________ _______.
_____ __________ _____ ____ ________.
_______ ______ _______ ________ ______ _____ _______.
_____ _________ ____ ________ ______.
______ _______ _____ ____ ___ ______ ______ ____ _____ _________.
_________ ____ _____ _______ ______ ___.
__________ _________ _________ ________ ____ _____ ____ _______.
______ _____ _______ _________ ____.
_____ ______ _______ ____ ___ __________ _______.
_____ ___ _____ ___ ________ _______ _____ ___ _________.
____ ___ ______ _______ _______ ___ _________ ____.
__________ __________ _____ ______ ________ ____ _________ ___ ____ ______ _______.
_________ ____ ___ _________ _______ _______ ______.
__________ _____ ______ _____ _____ __________ _________ ______ __________ _______.
_____ ________ _____ _________ ________ ______ _________ __________ ___ ______ _____.
_______ ________ _______ ______ ____ ________.
____ __________ _________ ____ _________ ______ ____ _____ ________ ____ __________ ____.
______ _________ _________ ______ ___ _______ __________ _______ ________ ___ ________ _____.
_____ _________ _______ ____ ____ _______ ________ _____ _________.
______ _______ ______ ______ _____ _____ _________ __________ ________.
________ __________ ________ ______ _________ ________ _____ ___.
________ ____ _______ ______ ____ ___ _______ _______ ___ ____ __________ ______.
_________ ________ ________ ___ ___ ___ ___ _____.
________ ________ _____ ________ __________ ______.
________ _______ _________ _____ _______ _____ _______ ___ __________ _______ _________ _____.
________ _____ _______ __________ _____ _______ ________.
____ _______ ___ _________ ____ __________.
_______ _____ _________ _________ ___ _______ ___ ______ ______ __________ _____ _______.
______ _________ ________ ____ _______ ___ _____ ______ _________.
____ _____ _________ _______ _______ _____ __________ ______.
______ _____ ____ ________ _____ ________ _____ _________ ___ ___ ________ ________.
________ ____ ______ ____ ___ ____ ______ __________.
__________ ______ ___ ____ __________ _______ ___ ________.
_______ ____ ______ _________ _______ __________ __________ ______ ___.
______ ___ ____ _____ _________ ____ ______ ______ _________.
____ ____ _____ ____ _________ ______ _______.
________ ________ ________ ___ _______ ____.
___ ________ __________ ________ _______ __________ ________ __________ _______ ____ ________.
____ __________ _____ ______ ____ _________ _____ ______ ___ ______.
____ _________ ______ ________ _________ ________ ______ ___.
______ __________ __________ ____ ______ _________ _______ _____ ____ __________ ___ _________.
__________ __________ _________ ____ __________ ______ ________ _________ _________ ____.
________ ___ ___ ____ _____ _____.
_________ ________ ______ __________ __________ _______ ____ ____ ___ _________.
__________ _________ _____ ____ _______.
_____ _________ ______ _________ _____.
_________ ________ ________ _______ _______ __________ ________.
_________ _______ _________ _________ ____ ________ ___.
__________ _________ ________ ________ _______ ______ _____ __________.
___ ____ ________ _______ __________ ______ ___ _________ ________ ________ _________.
__________ ____ ________ ________ ___.
_______ ____ ______ ______ ___ ____.
__________ _______ ____ ____ _______ ____ ______.
__________ ____ ____ _______ ___ _________.
_________ _____ ________ _______ _________.
______ __________ ________ __________ ________ ____ __________ ___.
______ ________ ____ ___ __________ _________ ___ ______ _______.
________ ___ ____ ________ _____ ______ ___ ___ ________ ______ ________.
____ ___ ____ __________ _____.
_________ ___ ____ _________ ______ ________ _____ __________ _________ _________ _________.
_____ ___ _______ __________ ___ _________ _______ ___ _____.
_________ ___ ________ ____ ___ __________ ________ ________.
_______ ________ ___ _____ _____.
___ ______ _____ _____ _________ ________ ________ _________.
______ ________ _____ ___ _______ _________ __________.
________ __________ __________ _______ __________ _________ __________ ___.
_________ _____ ________ ____ _________ __________ ________ ________ ________ _______ __________.
__________ _____ _________ ______ ______.
____ __________ _____ _________ ______ _________ __________ __________ _______ _________ ______.
________ ________ ______ _________ __________ ____ ___ ______ ______.
_________ ____ _______ ___ _________ ____ ______.
_______ ___ ___ ____ ______ _____ ___ ___ ______ ___ ___ __________.
__________ _________ _________ ____ _____ _________ ____ ____ __________ ________ ________.
________ ____ ___ __________ __________ ___ _____ _______.
__________ ____ ____ ______ __________ _____ ________ _____.
________ ___ _____ __________ ________ ______ ____ ______ ________ _________ ________ __________.
_______ _____ ______ __________ ________ ______ ___ _______ _________ ________ ________ __________.
_________ ___ _____ _________ __________.
_______ ___ __________ __________ __________ ________ ______ _____ _________ __________ ___ ________.
_______ ______ ____ _______ ________ ________.
___ ______ __________ _______ _________ _______ ___ ________ _______ ____ _______ __________.
____ _______ ____ ______ _____ ______ ______.
________ ___ ______ ________ _______ ______ _____ __________ ________ ___ ________ ______.
__________ ________ ____ _________ ___ _________ ______.
_____ ________ _________ __________ ____ ____.
__________ _________ ______ _______ ___ ______ _____ _______ ________.
_________ ______ ____ ____ _________.
____ ___ _________ ____ _______ _______ ________ ________.
_________ ___ _________ ___ ________ _______ ___ _____ ________ ______ _________ _______.
_____ ____ __________ _______ ____ ___ _______ ________ ______ ___.
___ ____ _____ _____ ___.
________ __________ ____ _______ _______ _________ ____ _______ ___.
_______ ______ __________ ____ ____ ________ __________ _______ ______ __________.
________ _______ ___ _________ ______ _____ ___ ________.
__________ ___ ____ ______ ________ _____ _______ _______ ____ __________ ____.
__________ ___ ________ _________ _________ _________ ___ _____.
____ ________ _______ ____ __________ __________ _______ _________ ________ __________ ________ ________.
___ _________ __________ ______ _____ ________ _______ _________ ________ ________ __________ ____.
________ __________ _________ ________ ___ _________.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU MCSL-083 2026 - Write a Python Program to implement the Min-Max Algorithm. | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→