//hex_board.cc #include "hex_board.h" hex_board::hex_board():SIZE(15) { int i; board = new testSquare* [15]; for (i = 0; i < 15; i++) board[i] = new testSquare[15]; makeBlankBoard(); } hex_board::hex_board(int largeness){ if (largeness < 1) largeness = 15; int i; board = new testSquare* [largeness]; for (i = 0; i < 15; i++) board[i] = new testSquare[largeness]; SIZE = largeness; makeBlankBoard(); } void hex_board::makeBlankBoard(){ int i, j; for (i=0; i=SIZE || l>=SIZE) continue; //Make sure the indices are in the valid range. if (board[k][l].contains == side && board[k][l].wasTested() == false) { if (directionConnected(k, l, side)) { result = true; break; } } } } return result; } bool hex_board::isWon(occupantType side) { int otherEdge, j; bool result = false; otherEdge = SIZE - 1; for(j=0; j < SIZE; j++) { if (side == VERT){ if(board[otherEdge][j].contains == VERT && board[otherEdge][j].wasTested() == false) { //We have to test whether the bottom is connected to the top. if(directionConnected(otherEdge, j, side)) { result = true; break; } } } else { if(board[j][otherEdge].contains == HORZ && board[j][otherEdge].wasTested() == false) { //We have to test whether the bottom is connected to the top. if(directionConnected(j, otherEdge, side)) { result = true; break; } } } } return result; } void hex_board::displayhex_board() { int i, j; int k; for(i=0;i> temp; cout << temp << "at" << i << ", " << j << "?"; if(temp==1) board[i][j].contains = VERT; if(temp==2) board[i][j].contains = HORZ; } } } int hex_board::numberOfEmpties() { int i,j; int total=0; for(i=0; i