-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (30 loc) · 1.23 KB
/
main.cpp
File metadata and controls
36 lines (30 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include "include/gomoku.h"
using namespace std;
int main(void) {
// Initialize Board Game
auto game = Omok();
int newX = 0, newY = 0;
bool res;
// Take in inputs until the game ends
while(!game.isFinished()) {
std::cout << std::endl << std::endl << game;
std::cout << "Give next piece location (ie. 1 2): \t";
std::cin >> newX;
std::cin >> newY;
std::cout << "Placing a piece at (" << newX << "," << newY << ")..." << std::endl;
// Place piece into game (or keep asking for new coords until it can happen)
res = game.placePiece(newX-1, newY-1);
while(!res) {
std::cout << "Invalid play made... Give corrected location (ie. 1 2): \t"; // Perhaps error reporting could be better in the API?
std::cin >> newX;
std::cin >> newY;
res = game.placePiece(newX-1, newY-1);
}
std::cout << "Is game finished? " << game.isFinished() << std::endl;
}
std::cout << "Final Board... Winner is Player " << game.getGameWinner() << "!" << std::endl;
std::cout << game << std::endl;
std::cout << "Game has finished..." << std::endl;
return 0;
}