Week 11: Exercises

1. Wythoff's Game

A certain game is played as follows. A chess queen is placed on a 8 x 8 chessboard, one square below the upper left corner. Two players alternate moves. On each player's turn, they must move the queen by any number of squares in one of three directions: either rightward, downward, or diagonally down and to the right. The first player to move the queen into the lower-right corner wins.

With perfect play, will the first player win or lose? Write a program to determine the answer.

2. Visual Wythoff

Extend the previous exercise by writing a graphical program that displays an 8 x 8 chessboard. Each square should be colored red if the player whose turn it is to move can always win from that square, blue otherwise.

3. Coin Game

Consider the following game. There is a row of N coins on the table, with values V1, V2, ... VN. On each player's turn, they can take either the first coin in the row or the last coin in the row. Write a method that takes an array with the values of the coins, and returns the maximum amount of money that the first player can win if both players play optimally.

4. Connect Four

Here is a GTK program that implements the game of Connect Four. It includes two computer players: one (Greedy) with a certain strategy, and another (MyStrategy) that moves randomly. Improve MyStrategy so that it can beat Greedy at least 75% of the time.