Question

Your task is to build an agent to play two versions (standard and misére) of the variant of a game called nim

(called red-blue nim against a human player). The game consists of two piles of marbles (red and blue). On each

players turn they pick a pile and remove one marble from it. If on their turn, either pile is empty then they lose in

the standard version and win in the misére version. The amount they lose (or win) is dependent on the number of

marbles left (2 for every red marble and 3 for every blue marble). So if on the computer player turn, it has 0 red

marbles and 3 blue marbles, it loses 9 points in the standard version (or wins 9 points in the misére version).

Your program should be called red_blue_nim and the command line invocation should follow the following

format:

red_blue_nim.py

and are required. (Number of red and blue marbles respectively)

is either

o standard - Player loses if either pile empty on their turn [default option if is not given]

o misere - Player wins if either pile empty on their turn

• can be

o computer - play a full game from given state with computer starting the game followed by human

[default option if is not given]

• human - play a full game from given state with human starting the game followed by computer

only used if depth limited search (Extra Credit) is implemented.

For a full game,

• On Computer turn, the program should use MinMax with Alpha Beta Pruning to determine the best move

to make and perform the move.

• Move ordering is pick blue marble followed by pick red marble for standard

• Move ordering is pick red marble followed by pick blue marble for misére

• On Human turn, the program should use a prompt to get the move from the human user and perform the

move.

The program should alternate between these turns till the game ends (when the players run out of either red or

blue marbles). Once the game ends, calculate who won and their final score and display it to the user.

Extra Credit (20 Points):

If your program determines computer move by using depth limited MinMax search with alpha beta pruning then

https://crystal.uta.edu/~gopikrishnav/classes/2023/fall/4308_5360/assets/assmt2.html

10/9/23,5:32 PM

Assignment 2

you will be given 20 points extra credit. You will need to come up with a eval function to use with the program

also. Please submit a text file describing the reasoning behind your eval function for full credit.

1/2

Question image 1