-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
140 lines (114 loc) · 4.34 KB
/
main.cpp
File metadata and controls
140 lines (114 loc) · 4.34 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#include <random>
#include <iostream>
#include "jsonify.h"
struct MapOptions {
int width;
int height;
int n_points;
int n_trees;
int n_sheeps;
int n_bushes;
std::string fn;
MapOptions(char* argv[], int argc): width(800), height(600), n_points(70), n_trees(10), n_sheeps(20), n_bushes(30), fn("db.json") {
for (int i = 1; i < argc; ++i) {
std::string arg = argv[i];
if ((arg == "-w" || arg == "--width") && i + 1 < argc) {
width = std::stoi(argv[i + 1]);
i++;
} else if ((arg == "-h" || arg == "--height") && i + 1 < argc) {
height = std::stoi(argv[i + 1]);
i++;
} else if ((arg == "-s" || arg == "--n-sheeps") && i + 1 < argc) {
n_sheeps = std::stoi(argv[i + 1]);
i++;
} else if ((arg == "-p" || arg == "--n-points") && i + 1 < argc) {
n_points = std::stoi(argv[i + 1]);
i++;
} else if ((arg == "-t" || arg == "--n-trees") && i + 1 < argc) {
n_trees = std::stoi(argv[i + 1]);
i++;
} else if ((arg == "-b" || arg == "--n-bushes") && i + 1 < argc) {
n_bushes = std::stoi(argv[i + 1]);
i++;
} else if ((arg == "-f" || arg == "--filename") && i + 1 < argc) {
fn = argv[i + 1];
i++;
}
}
}
};
int main(int argc, char* argv[]) {
MapOptions opts(argv, argc);
std::ofstream file;
file.open(opts.fn);
Map map(opts.width, opts.height, opts.n_points, opts.n_bushes, opts.n_trees, opts.n_sheeps);
json(map, file);
file.close();
// RoughObjectOptions opts;
// DB db;
// std::string fn = "db.db";
// db.connect(fn);
// std::vector<uint16_t> pts;
// for (size_t i = 0; i < map.roads.size(); ++i) {
// pts.clear();
// pts.push_back(map.points[map.roads[i].i].x);
// pts.push_back(map.points[map.roads[i].i].y);
// pts.push_back(map.points[map.roads[i].j].x);
// pts.push_back(map.points[map.roads[i].j].y);
// db._insert(RoughObjectType::LINE, opts, pts);
// }
// for (size_t i = 0; i < map.fields.size(); ++i) {
// pts.clear();
// pts.push_back(map.fields[i].a.x);
// pts.push_back(map.fields[i].a.y);
// pts.push_back(map.fields[i].b.x);
// pts.push_back(map.fields[i].b.y);
// pts.push_back(map.fields[i].c.x);
// pts.push_back(map.fields[i].c.y);
// db._insert(RoughObjectType::POLYGON, opts, pts);
// }
// for (size_t i = 0; i < map.trees.size(); ++i) {
// pts.clear();
// pts.push_back(map.trees[i].x);
// pts.push_back(map.trees[i].y);
// db._insert(RoughObjectType::CIRCLE, opts, pts);
// }
// for (size_t i = 0; i < map.bushes.size(); ++i) {
// pts.clear();
// pts.push_back(map.bushes[i].x);
// pts.push_back(map.bushes[i].y);
// db._insert(RoughObjectType::CIRCLE, opts, pts);
// }
// for (size_t i = 0; i < map.sheeps.size(); ++i) {
// pts.clear();
// pts.push_back(map.sheeps[i].x);
// pts.push_back(map.sheeps[i].y);
// db._insert(RoughObjectType::CIRCLE, opts, pts);
// }
// std::mt19937 eng;
// std::random_device r;
// std::seed_seq seed{r(), r(), r(), r(), r(), r(), r(), r()};
// eng.seed(seed);
// int N = 1'00;
// std::uniform_int_distribution<> w_dist(200, 800);
// std::uniform_int_distribution<> h_dist(200, 500);
// std::uniform_int_distribution<> p_dist(10, 100);
// std::uniform_int_distribution<> s_dist(10, 100);
// std::uniform_int_distribution<> f_dist(10, 100);
// std::uniform_int_distribution<> b_dist(10, 100);
// file.open("deaths.json");
// file << "[";
// int w, h, p, f, s, b;
// for (int i = 0; i < N; ++i) {
// w = w_dist(eng);
// h = h_dist(eng);
// p = p_dist(eng);
// s = s_dist(eng);
// f = f_dist(eng);
// b = b_dist(eng);
// json(Map(w, h, p, b, f, s), file);
// file << ",\n";
// }
// json(Map(w, h, p, b, f, s), file);
// file << "]";
}