summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2018-07-01 23:51:21 +0200
committerTom Smeding <tom.smeding@gmail.com>2018-07-01 23:51:42 +0200
commite0446e8653df1789893cb8530aafd3dd052b32ca (patch)
tree4f6ac60046a18cebc7abf4faf56e2572a2c14eda
parentbc51c3834928e388d16cc4b286da0574e3d94c32 (diff)
Time findMove in main
-rw-r--r--main.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/main.cpp b/main.cpp
index 0e16ec4..5eeb318 100644
--- a/main.cpp
+++ b/main.cpp
@@ -12,6 +12,14 @@ static void skipLine(istream &stream) {
while (stream.get() != '\n');
}
+static Move findMove(const Board &bd, int player) {
+ clock_t start = clock();
+ Move mv = AI::MM::findMove(bd, player);
+ clock_t diff = clock() - start;
+ cerr << "Time taken: " << (double)diff / CLOCKS_PER_SEC << " seconds" << endl;
+ return mv;
+}
+
int main() {
struct timeval tv;
gettimeofday(&tv, nullptr);
@@ -25,7 +33,7 @@ int main() {
char c = cin.peek();
if (c == 's' || c == 'S') {
skipLine(cin);
- Move mv = AI::MM::findMove(bd, onturn);
+ Move mv = findMove(bd, onturn);
assert(bd.isValid(mv, onturn));
cout << mv << endl;
bd.apply(mv);
@@ -60,7 +68,7 @@ int main() {
cerr << endl << bd << endl;
- mv = AI::MM::findMove(bd, onturn);
+ mv = findMove(bd, onturn);
assert(bd.isValid(mv, onturn));
cout << mv << endl;