-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThree.cpp
More file actions
44 lines (39 loc) · 1.13 KB
/
Copy pathThree.cpp
File metadata and controls
44 lines (39 loc) · 1.13 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
37
38
39
40
41
42
43
44
/**
* Basic Environment for Game 2048
* use 'g++ -std=c++11 -O3 -g -o 2048 2048.cpp' to compile the source
*
* Computer Games and Intelligence (CGI) Lab, NCTU, Taiwan
* http://www.aigames.nctu.edu.tw
*/
#include <iostream>
#include <fstream>
#include <iterator>
#include <string>
#include "board.h"
#include "solver.h"
int main(int argc, const char* argv[]) {
std::cout << "Three-Demo: ";
std::copy(argv, argv + argc, std::ostream_iterator<const char*>(std::cout, " "));
std::cout << std::endl << std::endl;
std::string solve_args = "";
int precision = 10;
for (int i = 1; i < argc; i++) {
std::string para(argv[i]);
if (para.find("--solve=") == 0) {
solve_args = para.substr(para.find("=") + 1);
} else if (para.find("--precision=") == 0) {
precision = std::stol(para.substr(para.find("=") + 1));
}
}
solver solve(solve_args);
board state;
state_type type;
state_hint hint(state);
std::cout << std::setprecision(precision);
while (std::cin >> type >> state >> hint) {
auto value = solve.solve(state, type);
std::cout << type << " " << state << " " << hint;
std::cout << " = " << value << std::endl;
}
return 0;
}