Due Tuesday, May 7 at 11:59 PM via Blackboard. Please submit your code (in .py or .cpp format) and write-up separately. Late assignments penalized 10% per day.
You can work in pairs on this assignment.
Each student must turn in their own, individual homework write-up along with the code.
Relevant Reading
Chapter 5, Sections 5.1 to 5.3.
Assignment
Starter code
We've provided starter code that plays a basic version of the game. The starter code, and the code you
will turn in, matches one computer player against a human (who enters moves interactively).
C++ Starter Code
The C++ starter code includes the following key functions:
Board * b = new Board();
The board has integer entires, with -1 indicating the O player, +1 indicating the X player, and zero indicating blank.
string boardStr = b->toString()
b->play_square(row,col,value)
where #row and col are 1 indexed(!).
int sq = b->get_square(row,col)
where where #row and col are 1 indexed.
int winner = b->winner()
bool full = b->full_board()
play()
Your task is to change the play() function, e.g. swap out the make_simple_cpu_move() function, to create a computer player that makes intelligent moves.\
You also need to change the starter code to allow the computer to play first (as the X player).
Python Starter Code
The Python starter code includes the same functions as documented for the C++ code above, with a few
minor differences (e.g., blanks are indicated with 'N' instead of 0, and the get square function is zero-indexed). Note, this code runs in Python 3.x; if you use 2.x, you may need to make small alterations to the code to get it to function.
What to turn in