-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
103 lines (90 loc) · 2.63 KB
/
main.cpp
File metadata and controls
103 lines (90 loc) · 2.63 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "Game/Application.h"
#include <iostream>
#include "Platforms/KamikazeRobot.h"
#include "Platforms/RobotCommander.h"
#include "Modules/Gun.h"
#include "Platforms/MobilePlatform.h"
#include "Modules/EnergyGenerator.h"
#include "Modules/Sensor.h"
#include "Platforms/RobotDestroyer.h"
#include "utils/CheckComponent.h"
#include "MenueLib/Menue.h"
#include <time.h>
#include <fstream>
int main(int argc, char* argv[])
{
Field::Field::GROUND_MODE_ON = false;
Field::Field::OBSTACLE_PERCENTAGE = 70;
Game::Application app = Game::Application(10, 10);
//hello
std::cout << "total points of interest: " << app.getField().total_poi << std::endl << std::endl;
std::cout << "Field:" << std::endl;
app.getField().consoleOutField();
//exit(0);
std::cout << std::endl;
std::cout << "Robots on field:" << std::endl;
std::vector<Robots::Platform*> potential_subs;
Robots::Platform* ruller;
for (auto it : app.getField().getPlatforms())
{
it.second->consoleOut();
if (!it.second->getIsMaster())
{
potential_subs.push_back(it.second);
}
else
{
ruller = it.second;
}
}
dynamic_cast<Robots::CommandCentre*>(ruller)->getCpu().setRadius(app.getField().getWidth()/2);
for (auto it : potential_subs)
{
try
{
dynamic_cast<Robots::CommandCentre*>(ruller)->getCpu().subdue(*it);
}
catch (std::invalid_argument)
{
continue;
}
}
std::cout << "fectively subdued: " << dynamic_cast<Robots::CommandCentre*>(ruller)->getCpu().getSubOrd().size() << std::endl;
/*auto itr = app.getField().getPlatforms().begin();
while(itr!= app.getField().getPlatforms().end())
{
itr.it->value.second->consoleOut();
~itr;
}*/
std::cout << std::endl << "Let's start the game!" << std::endl;
if (Dialogue::isArg(argv, argv + argc, "-ai"))
{
if (Dialogue::isArg(argv, argv + argc, "-wmode")) app.play();
else if (Dialogue::isArg(argv, argv + argc, "-mthread"))
{
double start = (double)time(NULL);
app.play_parallel();
double finish = (double)time(NULL);
//std::cout << std::endl << "Time passed: " << finish - start << std::endl;
printf("Time passed: %.10lf\n", (finish - start));
}
else
{
double start = (double)time(NULL);
app.play(false);
double finish = (double)time(NULL);
//std::cout << std::endl << "Time passed: " << finish - start << std::endl;
printf("Time passed: %.10lf\n", (finish - start));
}
}
else if (Dialogue::isArg(argv, argv + argc, "-sand-box"))
{
app.sandBox();
}
else
{
std::cout << "No mode specified. Bye!" << std::endl;
}
app.getField().cleanField();
return 0;
}