NAME____________________________________________________________________
PARTNER_________________________________________________________________
The game of othello is played on a 15 by 15 grid with flat stones. Each side of a stone has adifferent color. Two players alternate moves. On each move, a player places a stone with his colorup on an empty intersection of the grid. Each stone, except the first, must be placed immediatelyadjacent (horizontally, vertically, or diagonally) to an already placed stone. The first stone isautomatically placed at 7,7. When a stone is placed, if a line (horizontally, vertically, ordiagonally) of opposite stones is enclosed at both ends, then the color of the enclosed stones is flipped. The object of the game is to have the most stones on the board at the end of the game.
For example, in each of the cases below, the R stones would change to G because the underlined stone has been placed.
G R R R G G G G R R G
R R R R
R R G G
G G
Your task is to write a program which repeatedly prompts each player for his move and draws the grid as the game is played. After each move, the program writes the number of stones each playerhas on the board. You have a function MakeStone(row,column) which will draw a stone at the intersection of row and column. SetPenColor controls the stone color. Your program must contain the function enclosed(grid,row,column) which flips the color of any stones in grid enclosed by the stone at row, column.
Attached is a sample of program output and an explanation of the lab disk - read them both carefully.
An example dialogue produced by the program might be:
Player 1 = 1 Player 2 = 0
Player 2, what is your move?
Row: 6
Col: 7
Player 1 = 1 Player 2 = 1
Player 1, what is your move?
Row: 6
Col: 8
Player 1 = 2 Player 2 = 1
Player 2, what is your move?
Row: 5
Col: 8
Player 1 = 2 Player 2 = 2
Player 1, what is your move?
Row: 5
Col: 7
This will produce the following grid:

The lab disk contains the project othello.ide which contains othello.cpp. Create your program by modifying othello.cpp.
It is a graphic project, so as a reminder:
When you start C++, compile pcgraph.cpp as follows:
Open pcgraph.cpp, compile it (Alt+F9) , and close pcgraph.cpp.
Open othello.ide as follows:
Select Project|Open and select othello.ide - the title bar will show the project name.
If the program othello.cpp is not on the screen, open it.
Close othello.ide by selecting Project|Close.
Below is a listing of othello.cpp.
Try a compile and run, it will draw the stones in the printed sample.
/*
Program: othello - othello lab exercise
Programmer: <put your name here>
*/
#include "PCgraph3.h"
#include "othello.h"
int main(void)
{
// Your variables go here
// Do not remove InitGame( )
InitGame( );
// Your code goes below - replace the practice code
SetPenColor ("Red");
MakeStone(7,7);
SetPenColor("Green");
MakeStone(6,7);
SetPenColor("Red");
MakeStone(6,8) ;
SetPenColor("Green");
MakeStone(5,8);
SetPenColor("Red");
MakeStone(5,7);
return 0;
}