//***************************************************************************** // Include directives: #include "display.h" #include "strategy.h" #include using namespace std; // Display functions for the dots game. The game is displayed in // a graphics window with twenty pixels per dot plus a border of 20 extra. // There is also a space of 35 pixels at the bottom for messages. //***************************************************************************** //***************************************************************************** // Function implementations needed for the display part of the game. void clear_message( ) { // No work because we're just using text output. } void draw_state(const state& s) { // Draw the current board using ascii characters int row; int column; cout << " [1][2][3][4][5][6][7][8]" << endl; for(row = 1; row < BOARD_SIZE; row++) { cout << "[" << row << "] "; for(column = 1; column < BOARD_SIZE; column++) { if(s.board[row][column] == 0) cout << "___"; else if(s.board[row][column] == PLAYER1) cout << "_O_"; else if(s.board[row][column] == PLAYER2) cout << "_#_"; } cout << endl; } } void finish(const state& s) { // Print a message that says who won. switch(winner(s)) { case PLAYER1: cout << "You won."; break; case PLAYER2: cout << "You lose."; break; case 0: cout << "There is no winner."; break; } } void get_user_move(move& m) { // Prompt the user for a move. Read the two numbers. Put them into m.row and m.column. cout << "Type in the row and column number for your move: " << endl; cin >> m.row >> m.column; } void initialize_display( ) { // No work because we're just doing text output. } void write(const char message[]) { // Just print the message! }