-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainExample.cpp
36 lines (24 loc) · 1.02 KB
/
mainExample.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
30
31
32
33
34
35
36
//
// Created by Jérôme BUISINE on 16/07/2018.
//
#include <iostream>
#include <TreeNodeExample.h>
int main () {
srand(static_cast<unsigned int>(time(NULL)));
unsigned numberOfIterations = 1000;
auto rootNode = new TreeNodeExample(sqrt(2));
for(unsigned i = 0; i < numberOfIterations; i++){
rootNode->selectAction();
std::cout << "---------- Iteration " << i << "----------------------" << std::endl;
// display score information of each sub node
for(auto node : rootNode->getChildren()){
std::cout << "Node " << node->getIndex() << " (visited : " << node->getNVisits() << ")"
<< " : " << node->getScore() << std::endl;
}
}
TreeNode* nextNodeToUse = rootNode->getBestChild();
unsigned nodeIndex = nextNodeToUse->getIndex();
delete rootNode;
std::cout << std::endl << "----- Result -------------------" << std::endl;
std::cout << "Next node to use is [Node " << nextNodeToUse->getIndex() << "]" << std::endl;
}