Question

 

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

17 Feb 2026
Answer :
Word Count : 904
The Min-Max Algorithm is a decision-making algorithm used in game theory, particularly in two-player, zero-sum games. It is typically used in adversarial search, where two players take turns making moves, and each player's goal is to either maximize their chances of winning (for one player) or minimize the chances of the opponent winning (for the other player). The algorithm evaluates all possible moves by simulating each of the moves to their fullest extent, assuming both players play optimally. In this Python program, we will implement the Min-Max Algorithm for a simple game of Tic-Tac-Toe, where the computer will make its moves using the Min-Max algorithm to maximize its chances of winning, while the user will make their moves manually. The game assumes a player plays 'X' and the computer plays 'O'. The board is represented by a 3x3 matrix, and the computer will select the best possible move using the Min-Max strategy. Here is a Python implementation of the Min-Max Algorithm for Tic-Tac-Toe: ```python import math # Constants to represent the players PLAYER_X = 'X' PLAYER_O = 'O' EMPTY = ' ' # Function to check if the current player has won def check_winner(board, player): # Check rows, columns, and diagonals for i in range(3): if all([cell == player for cell in board[i]]): # Check row return True if all([board[j][i] == player for j in range(3)]): # Check column return True if all([board[i][i] == player for i in range(3)]): # Check diagonal return True if all([board[i][2 - i] == player for i in range(3)]): # Check other diagonal return True return False # Function to check if the board is full def is_full(board): return all([cell != EMPTY for row in
______ _________ _____ __________ ________ _______ __________ __________ __________ ______ _________ ______.
_____ ____ _________ _________ _______ ____ ____ _______ _____ _________ _____ __________.
__________ ________ _________ _______ _________.
_______ ______ _______ _____ __________ ______ ______.
________ ___ ____ ______ ___ ____.
_________ ______ __________ ________ __________ __________ _________ _________ __________ ____.
_______ __________ __________ __________ _________ ____.
________ __________ ____ ________ _____ ________ ________.
_________ ________ ____ ______ _______ ________ __________ __________ ______ ________ _________.
___ ___ _______ __________ _________ _________ __________ _________ ________.
_________ _______ ____ _____ ___ ___ ________.
_________ _________ _____ ________ _____ _______.
_______ ____ _____ ______ ____ ____ __________ ________ _____ ______ _________.
__________ ______ ______ __________ _______ ____ ____ _______.
_______ _______ _________ ______ _____ ____ _________ _______ _____.
_______ ___ ___ ________ _________ _________ ______ ____ __________ ________ ____.
______ ____ ________ _______ ______.
___ __________ ________ ____ _______ _____.
____ ______ _____ __________ __________ __________.
___ ___ ____ ____ ________ __________ ________ ___ _________ _____ _____ _______.
_______ _____ _________ _______ _____ ______ _______ ______ ___ _____.
____ ____ ___ ______ _______ __________.
_______ _______ ______ _______ ___ _______.
__________ ___ ________ ___ ___ ____.
___ ______ _____ _______ ______ ___.
____ ____ ____ ___ ______ _________ ______ __________ __________ ___ __________ ________.
_______ _______ _____ _____ ____ ____ _____ ________ _________ _______ ________ __________.
________ ___ _________ __________ _______ ___ ___ ______ ___ __________.
_______ __________ ____ ____ ____ _____ _______ ___ ______ ________ __________ ____.
_________ _________ ______ ______ _________ ______ ___.
__________ ___ _____ _____ __________ ___ _______ _____ ________.
________ __________ ______ _________ _____ ________ _______ _________ __________ ________ ____ __________.
____ ________ ________ ________ __________ _________ ________ _____ ________ ______ __________ ________.
______ ____ ____ ______ ___ ____ ____ ______ ______ ________ __________.
_______ ________ _____ _______ _____ _________ ____.
________ ________ ____ ________ ___ ______ _______ ________ _______ _________.
______ __________ _____ _____ _____ _____ _________ _______ ____ __________ ______.
________ ______ _________ _______ ______ ________ _______ _______ _____.
________ __________ ________ _________ _________ _______ _____ ______.
________ ______ ____ _______ ______ _______ _________ ___.
________ _____ ___ ______ _______ ________.
___ ______ _______ ______ ________ ______ _________ ________ ______.
____ ____ _______ ________ ________ ______ ________ ______ ______.
________ ________ _________ _____ _____ ____ _________ ________ ______.
____ ____ ______ ____ ______ ___ _______ ___.
___ ___ ________ ___ _________ ____ _____ _____ _____ ________.
___ _________ __________ __________ _______ _________ ___ ___ ____ __________ _______.
_______ _____ __________ ___ ____ _________ _______ _________ _________ _________ __________ ______.
__________ ______ __________ __________ ________ _________ __________ __________ ______.
______ ____ ________ ______ ____.
_________ ________ ________ _____ ______ ________ _________.
______ _________ ______ ________ _________ _____ _________ __________ ______ ____.
_______ _______ ________ _______ _____ __________ ______.
______ _________ __________ ______ _________ _____ _______ _________ _____.
________ _________ ____ ___ ___ ______.
__________ ________ _______ ____ _________ ______ ______ __________ _______ ____ ___.
___ _______ _______ _______ ____ _______.
________ ________ ____ _____ _____ ____ _____ ___.
_____ _________ ______ _______ ____ ________.
____ ____ __________ ______ __________ ______ ________ ___ ____.
___ ___ _____ _______ ______.
_______ _______ ______ ______ __________ ___ ____ _____ _____ __________.
_____ _______ _____ ____ _________ __________ _______ _________ _________ ___ _________.
______ ____ ________ _______ ________ _________.
_______ ____ ________ _________ __________ ______ ___ _________.
_____ ___ ___ ________ _________ ________ ______ ____ ____ _______ _______ ______.
________ ____ _______ _____ ____.
____ __________ _______ ____ __________ ________ ____ ______ _____.
____ _______ ____ _______ ______ ________ ______.
_______ _________ _____ _________ _____ _________ __________ _____.
___ _______ _________ _________ _____ __________ __________ _________ ________ __________ ___.
________ _____ _____ ______ ___ _____ _________ _________ _______ ________.
_________ _____ _____ ____ _____.
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 228 2026 -  Write a Python Program to implement the Min-Max Algorithm. | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→