-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap.h
More file actions
69 lines (57 loc) · 1.49 KB
/
Copy pathMap.h
File metadata and controls
69 lines (57 loc) · 1.49 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
#ifndef MAP_H
#define MAP_H
#include <iostream>
#include <string>
#include <vector>
#include <cstdint>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <cmath>
#include "Point.h"
#include "Errors.h"
#define MOVESET {'n','e','s','w'}
// custom hashs to use unordered_set. template gotten from https://en.cppreference.com/w/cpp/utility/hash
template<>
struct std::hash<Point>
{
std::size_t operator()(const Point& pt) const noexcept
{
std::size_t hash1 = std::hash<int>{}(pt.lat);
std::size_t hash2 = std::hash<int>{}(pt.lng);
return hash1 ^ (hash2 << 1);
}
};
template<>
struct std::hash<std::tuple<int,int,int>>
{
std::size_t operator()(const std::tuple<int,int,int>& tup) const noexcept
{
std::size_t hash1 = std::hash<int>{}(std::get<0>(tup));
std::size_t hash2 = std::hash<int>{}(std::get<1>(tup));
std::size_t hash3 = std::hash<int>{}(std::get<2>(tup));
return ((hash1 ^ (hash2 << 1)) >> 1) ^ (hash3 << 1);
}
};
struct pstate {
Point pt;
int bomb_count;
std::string path;
double dist;
std::unordered_set<Point> changed;
};
class Map {
int map_width;
int map_height;
std::vector<std::vector<char>> map;
std::unordered_set<Point> walls;
std::unordered_set<Point> waters;
public:
Map(std::istream& stream);
// ~Map();
void print();
std::string route(Point src, Point dst);
};
bool operator < (pstate state1, pstate state2);
#endif