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