Posted on

Your task is to implement in Python the following adversarial search algorithms refer to lecture

Your task is to implement in Python the following adversarial search algorithms (refer to lecture slides and/or your textbook for details | pseudocode provided below): MiniMax (as specified by the MINIMAX-SEARCH pseudocode below) When the game is complete, your program should display a corresponding message: X WON or O WON TIE X LOST or O LOST MiniMax with alpha-beta pruning (as specified by the ALPHA-BETA-SEARCH pseudocode below), and apply them to play the game of Tic-Tac-Toe (computer). Using any other approach is not going to be accepted. Problem input/command line interface: Your program should: Accept three (3) command line arguments, so your code could be executed with python cs480_P01_AXXXXXXXX.py ALGO FIRST MODE where: - cs480_P01_AXXXXXXXX.py is your python code file name, - ALGO specifies which algorithm the computer player will use: 1 - MiniMax, 2 - MiniMax with alpha-beta pruning, - FIRST specifies who begins the game: X When it is human player's turn, your program should display the following prompt: X's move. What is your move (possible moves at the moment are: | enter 0 to exit the game)? where: is a sorted list of all available moves at the moment, for example, if the board arrangement is: and it is X's move, the prompt should be: What is your move (possible moves at the moment are: 2, 3, 7, 9) | enter 0 to exit the game)? If the user enters anything other than 0/ valid move number (0 should terminate the game) your program should repeat the prompt above. Once the user enters a valid move, display the updated game board on screen. When it is the computer's turn (regardless of the game mode), your program should display (it could be an 'X' or 'O' move): X's selected move: Z. Number of search tree nodes generated: A.A.A where: - Z is the move/action number (a positive integer from the {1, 2, 3, 4, 5, 6, 7, 8, 9} set) selected by computer - A.A.A is the number of search tree nodes generated (the number of MiniMax nodes computer explored before making the decision [including "root"]) to select it. Follow it with the updated game board on screen. - NOTE!!! Computer's search tree move exploration order should be in a sorted fashion (1, 2, 3, 4, 5, 6, 7, 8, 9 | assuming HERE that ALL moves are available). 2 - computer (X) versus computer (O), Example: python cs480_P01_A11111111.py 2 X 1 If the number of arguments provided is NOT three (none, one, two or more than three) or arguments are invalid (incorrect ALGO, FIRST or MODE) your program should display the following error message: ERROR: Not enough/too many/illegal input arguments. and exit. Program details: Specific program details: The Tic-Tac-Toe game board is represented by 3x3 grid with cells numbered as follows - Possible moves/actions for both players match cell numbers (if a player wants to place an 'X' in the middle of the board, the move/action is '5'), Your program should begin by displaying the following information: Last Name, First Name, Axxxxxxxx solution: Algorithm: MiniMax with alpha-beta pruning First: X Mode: human versus computer where: - Axxxxxxxx is your IIT A number, - Algorithm is the algorithm specified by a command line argument, - First is the information who makes the first move as specified by a command line argument, - Mode is the game mode as specified by a command line argument, If the game mode is human versus computer display an empty board first and prompt the user to pick the move (see below)

Your task is to implement in Python the following adversarial search algorithms (refer to lecture slides and/or your textbook for details | pseudocode provided below): MiniMax (as specified by the MINIMAX-SEARCH pseudocode below)

When the game is complete, your program should display a corresponding message: X WON or O WON TIE X LOST or O LOST

MiniMax with alpha-beta pruning (as specified by the ALPHA-BETA-SEARCH pseudocode below), and apply them to play the game of Tic-Tac-Toe (computer). Using any other approach is not going to be accepted.

Problem input/command line interface: Your program should:
Accept three (3) command line arguments, so your code could be executed with python cs480_P01_AXXXXXXXX.py ALGO FIRST MODE where:
– cs480_P01_AXXXXXXXX.py is your python code file name,
– ALGO specifies which algorithm the computer player will use: 1 – MiniMax, 2 – MiniMax with alpha-beta pruning,
– FIRST specifies who begins the game: X

When it is human player’s turn, your program should display the following prompt: X’s move. What is your move (possible moves at the moment are: | enter 0 to exit the game)? where: is a sorted list of all available moves at the moment, for example, if the board arrangement is: and it is X’s move, the prompt should be: What is your move (possible moves at the moment are: 2, 3, 7, 9) | enter 0 to exit the game)? If the user enters anything other than 0/ valid move number (0 should terminate the game) your program should repeat the prompt above. Once the user enters a valid move, display the updated game board on screen.

When it is the computer’s turn (regardless of the game mode), your program should display (it could be an ‘X’ or ‘O’ move): X’s selected move: Z. Number of search tree nodes generated: A.A.A where:
– Z is the move/action number (a positive integer from the {1, 2, 3, 4, 5, 6, 7, 8, 9} set) selected by computer
– A.A.A is the number of search tree nodes generated (the number of MiniMax nodes computer explored before making the decision [including “root”]) to select it. Follow it with the updated game board on screen.
– NOTE!!! Computer’s search tree move exploration order should be in a sorted fashion (1, 2, 3, 4, 5, 6, 7, 8, 9 | assuming HERE that ALL moves are available).

2 – computer (X) versus computer (O),
Example: python cs480_P01_A11111111.py 2 X 1

If the number of arguments provided is NOT three (none, one, two or more than three) or arguments are invalid (incorrect ALGO, FIRST or MODE) your program should display the following error message: ERROR: Not enough/too many/illegal input arguments. and exit.

Program details: Specific program details: The Tic-Tac-Toe game board is represented by 3×3 grid with cells numbered as follows –
Possible moves/actions for both players match cell numbers (if a player wants to place an ‘X’ in the middle of the board, the move/action is ‘5’),

Your program should begin by displaying the following information:
Last Name, First Name, Axxxxxxxx solution:
Algorithm: MiniMax with alpha-beta pruning
First: X
Mode: human versus computer

where:
– Axxxxxxxx is your IIT A number,
– Algorithm is the algorithm specified by a command line argument,
– First is the information who makes the first move as specified by a command line argument,
– Mode is the game mode as specified by a command line argument,

If the game mode is human versus computer display an empty board first and prompt the user to pick the move (see below)


 
Solved By Verified
Study Co-Pilot All Study Co-Pilots are evaluated by Gotit Pro as an expert in their subject area.

 
Instant
Download

Student review: (6 ratings) 6 out of 6 people found this solution helpful.