-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_map.cpp
More file actions
54 lines (43 loc) · 1.28 KB
/
Copy pathgenerate_map.cpp
File metadata and controls
54 lines (43 loc) · 1.28 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
/* Lab Name: Path Finding
* Names: Pravin Adithya Srinivasan, Manihams Suraparaju
* Resources: Lecture notes, youtube video, geeksforgeeks, github
*/
#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(int argc, char* argv[]) {
if (argc != 2) {
cerr << "Usage: ./generate_map N\n";
return 1;
}
// map size (n*n)
int mapSize = stoi(argv[1]);
srand(time(0));
// Initialized the tile types and costs
vector<pair<char, int>> tileCost = {
{'f', 3}, {'g', 1}, {'G', 2},
{'h', 4}, {'m', 7}, {'r', 5}
};
// Outputs each map and its cost
cout << tiles.size() << endl;
for (auto& t : tiles) {
cout << t.first << " " << t.second << endl;
}
// Output map dimensions getting rows and columns
cout << N << " " << N << endl;
// Calculates and prints the map grid with random tiles
for (int i = 0; i < N; ++i) {
for (int j = 0; j < N; ++j) {
int idx = rand() % tiles.size();
cout << tiles[idx].first;
if (j != N - 1) cout << " ";
}
cout << endl;
}
// Output start and end positions from top-left to bottom right
cout << "0 0" << endl;
cout << N-1 << " " << N-1 << endl;
return 0;
}