Write a Python Program to implement Min-Max Algorithm.
import math
# Constants for the game
PLAYER_X = 'X'
PLAYER_O = 'O'
EMPTY = ' '
def print_board(board):
"""Function to print the Tic-Tac-Toe board"""
for row in board:
print(" | ".join(row))
print("-" * 5)
def is_winner(board, player):
"""Check if the player has won"""
win_conditions = [
# Check rows
[board[0][0], board[0][1], board[0][2]],
[board[1][0], board[1][1], board[1][2]],
[board[2][0], board[2][1], board[2][2]],
# Check columns
________ _____ __________ ____ _____ __________.
_____ ______ ___ ____ ______ _____ __________ ____ ______ _________ ________.
______ _______ __________ ___ ___ ______ ___ ____ ______ ______ _____.
_____ _______ ______ ______ _____ ____ __________ _____ ________ __________ _________ ___.
___ ______ ________ ________ ________ ____.
_______ _____ _________ ________ ______ _____ ____ _________ _________ _____ _______ _______.
______ ________ ________ _______ _____ __________ ______ ____ _________ ___.
___ __________ _______ __________ _____ __________ _________ __________ __________ _______ __________ ________.
____ _____ ______ _________ _____ ________ __________ _______ ______ ________ __________.
_______ _______ __________ ____ _________ _____ __________.
___ ________ __________ _______ ________ ______ _______ __________ _____ ____ ____ ________.
________ __________ ______ ______ _________ ______ ____.
___ ___ ____ ___ _________ _________ _______ _______ _______ ________ _____ ___.
_____ __________ _____ _________ ______.
_________ __________ _________ __________ _________ ____ ________.
______ ________ ___ ___ _____ ____ ________.
____ _____ ________ ___ _____.
___ ___ ___ _______ _____ ______.
_______ _____ _______ ___ ______ ______ ____ __________ ____.
________ _________ ____ ___ ____ _______.
___ ______ __________ ____ ___ ______ ____ ________ ________ _______ _________.
____ ______ _____ ______ __________ ______ ___ ___ ___.
______ _________ _____ _________ _________ ______ _______ __________ _____.
_________ ________ ____ __________ ______ _____.
_________ _________ __________ _______ __________ __________ ___ __________ _________ ____ ___ __________.
______ _____ __________ _________ ________ ___ ______ ____ ____ _______ _______.
_____ __________ ___ ______ _____ ______ ____ _________ _______ ______.
__________ _____ ______ _______ ________ _____.
_______ ______ _________ ________ ____ __________ ____ __________ ____ _______ ___ ___.
______ ______ _____ ________ ________ ________ ___ __________ _________ ____.
____ _____ _____ _____ _______ ___ __________ _____ ___.
___ ________ ______ ___ __________.
_____ _____ _________ ____ _________ _______ ___ ___ ________ ___.
_________ _______ _______ _____ ______ __________ _____ ______ ________ _____ ____ ________.
__________ _______ ______ __________ ________ ______.
________ _______ ________ ____ __________ ________ ______ ___ __________ ________.
_________ _______ ______ __________ __________ _____ __________ _________ __________.
____ _____ ____ ____ ______ _________ _______.
________ __________ ________ _____ ____ _________ _____ _____ ________.
________ ______ ____ ______.
Get Full Answer on WhatsApp