-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.cpp
69 lines (62 loc) · 2.28 KB
/
map.cpp
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
#include <cassert>
#include <iostream>
#include "map.h"
// static const char map[] = "0000222222220000"\
// "1,,,, 5"\
// "1 , 5"\
// "1 01111 5"\
// "0 0 5"\
// "0 3 1155"\
// "0 1000 5"\
// "0 3 0 5"\
// "5 4 100011 5"\
// "5 4 1 4"\
// "0 1 4"\
// "2 1 44444"\
// "0 000 4"\
// "0 111 4"\
// "0 4"\
// "0002222244444444";
static const char map[] = "00000000000000011111112144444444\
0 0 0 1 4\
0 0 01 1 1 4\
0 0 01 11 2 14 4\
0 0 02 211 1 14 4 4\
0000 01 1 1 14 445444\
0 01 1111 14 4\
0 02 1 14 4\
000000000001 1 33 24 4 4\
666666666661 1 144544 4\
6 61 1 3 111 14 4\
6 61 1 3 1 14 4\
667 76 61 1 14 4 4\
6 6 61 1 14 445444\
6 6 61 1 3 3 14 4\
6 66 61 1 3 3 3 14 4\
66666 66661 14 4 4\
6 6 6 111121111211144544 4\
6 8 8 66666666666664 4\
6666 66666 64 4\
6 6 64 4 4\
6 6 666 64 445444\
6 9 66666 6 64 4\
6 9 6 666 64 4\
6 9 6 6 64 4\
6 6 6 64 4\
6 6 66666 66 6445444 4\
6 6666666666 6 64 4\
6 6 64 4\
6 6 64 4\
6 6 4\
66676767676666666666666644444444";
Map::Map() : w(32), h(32) {
assert(sizeof(map) == w*h+1); // +1 for the null terminated string
}
int Map::get(const size_t i, const size_t j) const {
assert(i<w && j<h && sizeof(map) == w*h+1);
return map[i+j*w] - '0';
}
bool Map::is_empty(const size_t i, const size_t j) const {
assert(i<w && j<h && sizeof(map) == w*h+1);
return (map[i+j*w] == ' ');
}