//hexRandom.cc 11/23 #include "RandomAnalysis.h" // One is first asked for the board size. Enter n for an n by n hex board. // You play H, for horizontal, and the program plays V, for vertical. //The goal is for the player to connect the left to the right, horizontally, //and the computer the top to the bottom, vertically. //You play by entering the coordinates of your move. int main() { hex_board theBoard; RandomAnalysis guessing; int i,j; int a, b; Move compMove; Move here; bool gameOver = false; int firstval, secondval; int size; cout << "Input board size " << "\n"; cin >> size; theBoard = hex_board(size); theBoard.displayhex_board(); while(gameOver == false) { cout << "Input x-value: " << "\n"; cin >> a; cout << "Input y-value: " << "\n"; cin >> b; if (b == -99 ) break; firstval = size - b; secondval = a - 1; if (firstval < 0 || firstval >= size || secondval < 0 || secondval >= size) { cout << "Move invalid" << "\n"; continue; } if (theBoard.board[firstval][secondval].contains == EMPTY ) { cout << "Good move " << "\n"; } else continue; here = Move(firstval, secondval); theBoard.doIt(here, HORZ); if (theBoard.isWon(HORZ)) { gameOver = true; cout << "You won" << "\n"; break; } guessing = RandomAnalysis(theBoard, VERT); compMove = guessing.choose_move(); theBoard.doIt(compMove, VERT); theBoard.displayhex_board(); if (theBoard.isWon(VERT)) { gameOver = true; cout << "You lost " << "\n"; } if (theBoard.numberOfEmpties()==0) break; } return 0; }