Reversi/Othello game

I am making a Reversi game where 2 AI's have to play against eachother. So far i have code where humans play but i need a program where only 2 AI's play.

Here is the code I have:

using namespace std;
const int NUM_ROWS = 8, NUM_COLS = 8;
void initialize_game_board(int gb [][NUM_COLS]);
void display_gameboard_row(unsigned int rownum, int gb [][NUM_COLS]);
void display_gameboard(int gb [][NUM_COLS]);
void display_cell_top();
void display_cell_side(char cell_middle);
int main()
{
int player_choice = 0;
int gameboard [NUM_ROWS][NUM_COLS];
int player, opponent;
player_choice = determine_game_type_new_or_existing();
display_gameboard(gameboard);
int row, col;
cout << "Make your move.\n\n"
<< "Row: ";
cin >> row;
while (row < 0 && row > 7)
{
cout << "Please enter a valid move between 0-7.\n";
cout << "Make your move.\n\n"
<< "Row: ";
cin >> row;
}
cout << endl << endl
<< "Column: ";
cin >> col;
while (col < 0 && col > 7)
{
cout << "Please enter a valid move between 0-7.\n";
cout << "Make your move.\n\n"
<< "Column: ";
cin >> col;
}
return 0;
}

void initialize_game_board(int gb[][NUM_COLS])
{
//This is a nested loop to make sure every cell is empty
//Cell Codes: 0 = empty, 1 = white piece, 2 = black piece
for (int i = 0; i < NUM_ROWS; i++)
{
for (int j = 0; j < NUM_COLS; j++)
gb[i][j] = 0;
}
gb[3][3] = 1;//Put down white piece
gb[4][4] = 1;//Put down white piece
gb[3][4] = 2;//Put down black piece
gb[4][3] = 2;//Put down black piece
}
void display_gameboard(int gb [NUM_ROWS][NUM_COLS])
{
for (unsigned int num = 0; num < NUM_ROWS; num++)
{
cout << " ";
display_gameboard_row(num, gb);
}
cout << " ";
for(unsigned int num = 0; num < NUM_COLS; num++)
display_cell_top();//Displays a horizontal line
cout << '+' << endl;
}
void display_gameboard_row(unsigned int rownum, int gb [NUM_ROWS][NUM_COLS])
{
for (unsigned int num = 0; num < NUM_COLS; num++)
display_cell_top();//Displays a horizontal line
cout << '+' << endl;
cout << " ";
for (unsigned int num = 0; num < NUM_COLS; num++)
{
display_cell_side(' ');//Displays a vertical line
}
cout << '|' << endl;
cout << " ";
for (unsigned int col = 0; col < NUM_COLS; col++)
{
//char game_piece;//Either space, W or B
if ( gb[rownum][col] == 0 )
display_cell_side (' ');
else if ( gb[rownum][col] == 1 )
display_cell_side ('W');
else if ( gb[rownum][col] == 2 )
display_cell_side ('B');
else
{
cout << "An internal error has occurred." << endl;
//exit (2);
//return 2;
}
}
cout << '|' << endl;
cout << " ";
for (unsigned int num = 0; num < NUM_COLS; num++)
display_cell_side(' ');//Displays a vertical line
cout << '|' << endl;
}
void display_cell_top()
{
string cell_top = "+------";
cout << cell_top;
}
void display_cell_side(char cell_middle)
{
string cell_left_side = "| ";
//string cell_middle = " ";
string cell_right_side = " ";
cout << cell_left_side << cell_middle << cell_right_side;
}
Topic archived. No new replies allowed.