-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
64 lines (50 loc) · 2.19 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <thread>
#include "Map.h"
#include "Agent.h"
using namespace std;
int main() {
int userChoice = 0;
int s = MAX_LEARNING_RATE * TEST_NUMBER *
stoi(to_string(chrono::duration_cast<chrono::seconds>(TEST_DURATION).count()).substr(0, to_string(
chrono::duration_cast<chrono::seconds>(TEST_DURATION).count()).find('s'))) / 60;
while (userChoice != 1 && userChoice != 2 && userChoice != 3 && userChoice != 4) {
cout << " Welcome to the Roomboss experience !\n\n We have different modes available :\n"
" 1 - Run Roomboss with a BFS algorithm, paired with Roomboss's best learning rate.\n"
" 2 - Run Roomboss with a A* algorithm, paired with Roomboss's best learning rate.\n"
" 3 - Run Roomboss with our second A* algorithm (read report page 21 before)\n"
" 4 - Make Roomboss run a " << s << "min test to estimate the best learning rate for him. "
"(read report page 11 before)\n"
"\tHe will then start running with a A* algorithm and this best learning rate.\n\n"
" In all choices, when the map prints, each cell of the map is represented by a . : \n"
" - the cell where Roomboss is located is represented by V, \n"
" - cells containing jewels or dust are represented by J or D respectively, \n"
" - cells containing two elements are represented by their two letters,\n"
" - and cells containing all three elements are represented by an A." << endl;
cout << endl << "Input : ";
cin >> userChoice;
cin.clear();
cin.ignore(1000, '\n');
}
int wait_time;
cout << "\nPlease enter waiting time for readability\nEnter 0 if you want no pauses" << endl;
cout << "Input : ";
while (!(cin >> wait_time)) {
cin.clear();
cin.ignore(1000, '\n');
cout << "Invalid input (must be a number). Try again: ";
}
cout << endl;
srand(time(nullptr));
Agent *vacuum;
Map *mp = new Map();
if (userChoice == 1)
vacuum = new Agent(mp, false);
else
vacuum = new Agent(mp, true);
thread env(&Map::objSpawn, mp, wait_time);
thread roomba(&Agent::agentWork, vacuum, userChoice, wait_time);
env.join();
roomba.join();
return 0;
}