
# assignment: programming assignment 1
# author: Nirmal Jasti
# date: 1/20/2024
# file: tictac.py is a program that simulation
#       of moves in tictactoe.
# input: The location of the chess pieces.
# output:The moves that certain chess pieces can makes. 


from board import Board
from player import Player, AI, MiniMax
# main program
print("Welcome to TIC-TAC-TOE Game!\n")
while True:
    board = Board()
    player1 = Player("Bob", "X")
    player2 = Player("Alice", "O")
    player1 = MiniMax('Max', 'X',board)
    turn = True

    while True:
        board.show()
        if turn:
            player1.choose(board)
            turn = False
        else:
            player2.choose(board)
            turn = True

        if board.isdone():
            board.show()
            break
        

    if board.get_winner() == player1.get_sign():
        print(f"{player1.get_name()} is a winner!")
    elif board.get_winner() == player2.get_sign():
        print(f"{player2.get_name()} is a winner!")
    else:
        print("It is a tie!")

    ans = input("Would you like to play again? [Y/N] \n").upper()
    if ans != "Y":
        break
    print()    
print("Goodbye!")


