-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
executable file
·29 lines (24 loc) · 891 Bytes
/
main.cpp
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
#include "game/Game.h"
int main(int argc, char *argv[]) {
// Set default game settings.
unsigned int moves = 21;
dimension width = 18, height = 18;
unsigned short int colors_num = 4;
vector<unsigned short int> valid_input_lengths = {1, 2, 4, 5};
// Check input.
if ((find(valid_input_lengths.begin(), valid_input_lengths.end(), argc) == valid_input_lengths.end()) ||
((argc >= 2) && (string(argv[1]) == "-h"))) {
throw runtime_error("Usage: coloring [MOVES (21)] [WIDTH (18)] [HEIGHT (18)] [COLOR_NUM (4)]");
}
// Parse arguments.
if (argc >= 2) moves = stoi(argv[1]);
if (argc >= 4) {
width = stoi(argv[3]);
height = stoi(argv[2]);
}
if (argc == 5) colors_num = stoi(argv[4]);
// Initialize the game.
Game game(moves, width, height, colors_num);
// Play.
return game.play() ? 0 : 1;
}