Assignment 2
Game Playing Problems
Max possible score:
- 4308: 100 Points [+40 Points EC]
- 5360: 100 Points [+40 Points EC]
Task Description
Your
task is to build an agent to play two versions (standard and misère)
of a 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 or two marbles from it (if possible). 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 by default for every red marble and 3 by default 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 <num-red>
<num-blue> [-r
<value>] [-b
<value>] [-<version>]
[-<first-player>] [-c] [-mo] [-d <depth>]
- <num-red> and <num-blue> are required. (Number of red
and blue marbles respectively)
- -r <value>: The value of a red marble [2 by default if
option not used]
- -b <value>: The value of a blue marble [3 by default if
option not used]
- -<version>: is either
- default [flag not given]: standard - Player loses if either
pile empty on their turn
- -m: misere - Player wins if either pile empty on their turn
- -<first-player>: can be
- default [flag not given]: computer
- play a full game from given state with computer starting the game
followed by human
- -hf: human - play a full game from given state with human
starting
the game followed by computer
- -c: cache minmax values to prevent recaclulating them. [Do not cache values if option is not used]
- -mo: only used if dynamic move ordering (Extra Credit) is
implemented. Rearrange move ordering whenever pruning occurs. [Static
move ordering if option is not used]
- -d <depth>: only used if depth limited search (Extra
Credit) is implemented. Set depth limit to given value. [Search is not depth limited if option is not used]
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.
- For move ordering in standard version (if you are not implementing the extra credit task), use:
- Pick 2 red marble
- Pick 2 blue marble
- Pick 1 red marble
- Pick 1 blue marble
- For misère version (if you are not implementing the extra credit task), invert the above order.
- 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 (Upto 40 Points):
If your program caches MinMax values in a Transposition Table (A hash
table with the board configuration as the key) and uses that to avoid
recalculating minmax values of game configurations it has already done
the work for, then you will be given 15 points extra credit. Please
note you have to either make the player info part of the hash or store
a seperate table for each player.
If instead of using the static move ordering given, you program
rearranges the move ordering whenever pruning occurs, ensuring that the
move that results in pruning gets evaluated first the next time, then
you will be given 10 points extra credit. Please note you will have to
maintain seperate move ordering for each player if you do this.
If your program determines computer move by using depth limited MinMax
search with alpha beta pruning, then you will be given 15 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.
How to submit
Implementations in C, C++, Java, and Python will
be accepted. Points will be taken off
for failure to comply
with this requirement unless previously cleared with the Instructor.
Create a ZIPPED
directory called <net-id>_assmt.zip (no other
forms
of compression
accepted, contact the instructor or TA if you do not know how to
produce .zip files).
The directory should contain the source code for the task (no need for
any compiled binaries). Each
folder should also contain a file called readme.txt, which
should specify precisely:
- Name and UTA ID of the student.
- What programming language is used for this task. (Make sure to
also give version and subversion numbers)
- How the code is structured.
- How to run the code, including very specific compilation
instructions,
if compilation is needed. Instructions such as "compile using g++" are
NOT considered specific if the TA needs to do additional steps to get
your code to run.
- If your code will run on the ACS Omega (not required) make a
note of it in the readme file.
- Insufficient or unclear instructions will be penalized.
- Code that
the TA cannot run gets AT MOST 75% credit (depending on if the student
is able to get it to run during a Demo session).