-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
46 lines (38 loc) Β· 1.9 KB
/
Copy pathmain.cpp
File metadata and controls
46 lines (38 loc) Β· 1.9 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
#include <chrono>
#include <thread>
#include <iostream>
#include "Config.hpp"
#include "SwarmSimulation.hpp"
#include "ConsoleRenderer.hpp"
#include "PpmRenderer.hpp"
int main(int argc, char** argv) {
SimConfig cfg = loadConfigFromArgs(argc, argv);
SwarmSimulation sim(cfg);
ConsoleRenderer console;
PpmRenderer ppm(cfg.renderImageW, cfg.renderImageH, cfg.renderFramesDir);
std::cout << "\033[1;35m";
std::cout << "ββββββββββββββββββββββββββββββββββββββββββ\n";
std::cout << "β HIVEFLIGHT DRONE SWARM SIMULATION β\n";
std::cout << "β Algorithm: Reynolds Boids + Target β\n";
std::cout << "ββββββββββββββββββββββββββββββββββββββββββ\n";
std::cout << "\033[0m";
std::cout << "Drones: " << cfg.droneCount << " | dt=" << cfg.dt
<< " | steps=" << cfg.steps << " | seed=" << cfg.seed << "\n";
std::cout << "World: " << cfg.worldWidth << "x" << cfg.worldHeight << "\n";
std::cout << "Render PPM: " << (cfg.renderPpm ? "true" : "false") << "\n\n";
std::this_thread::sleep_for(std::chrono::seconds(1));
for (int step = 0; step < cfg.steps; ++step) {
if (step % 2 == 0) {
console.print(sim.drones(), sim.obstacles(), sim.targets(),
step, sim.time(), cfg);
}
if (cfg.renderPpm && (step % cfg.renderEvery == 0)) {
ppm.render(sim.drones(), sim.targets(), step, sim.config());
}
sim.step();
std::this_thread::sleep_for(std::chrono::milliseconds(cfg.sleepMs));
}
console.printStats(sim.drones(), sim.tick(), sim.time(), sim.obstacles());
std::cout << "\n\033[1;32mSimulation complete!\033[0m\n";
return 0;
}