aboutsummaryrefslogtreecommitdiff
path: root/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'map.c')
-rw-r--r--map.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/map.c b/map.c
index d0e48a6..3859bd9 100644
--- a/map.c
+++ b/map.c
@@ -72,6 +72,48 @@ unsigned int neighbours_4dir(Position neighbour_array[4], size_t cost_array[4],
return cur;
}
+unsigned int neighbours_4dir_wraparound(Position neighbour_array[4], size_t cost_array[4], Position pos, size_t width, size_t height, \
+ char **visited, size_t **costs) {
+ size_t cur = 0;
+
+ Position poses[4];
+ if (pos.x == 0) /* Left */
+ poses[0] = (Position) { .x = width - 1, .y = pos.y };
+ else
+ poses[0] = (Position) { .x = pos.x - 1, .y = pos.y };
+
+ if (pos.y == 0) /* Up */
+ poses[1] = (Position) { .x = pos.x, .y = height - 1 };
+ else
+ poses[1] = (Position) { .x = pos.x, .y = pos.y - 1};
+
+ if (pos.x == width - 1) /* Right */
+ poses[2] = (Position) { .x = 0, .y = pos.y };
+ else
+ poses[2] = (Position) { .x = pos.x + 1, .y = pos.y };
+
+ if (pos.y == height - 1) /* Down */
+ poses[3] = (Position) { .x = pos.x, .y = 0 };
+ else
+ poses[3] = (Position) { .x = pos.x, .y = pos.y + 1};
+
+ for (int i = 0; i < 4; i++) {
+ Position p = poses[i];
+
+ if (!visited[p.y][p.x]) {
+ neighbour_array[cur].x = p.x;
+ neighbour_array[cur].y = p.y;
+ if (cost_array != NULL) {
+ if (costs != NULL) cost_array[cur] = costs[p.y][p.x] * COST_ORTHOGONAL;
+ else cost_array[cur] = COST_ORTHOGONAL;
+ }
+ cur += 1;
+ }
+ }
+
+ return cur;
+}
+
unsigned int neighbours_8dir(Position neighbour_array[8], size_t cost_array[8], Position pos, size_t width, size_t height, \
char **visited, size_t **costs) {
size_t cur = 0;
@@ -152,6 +194,12 @@ unsigned int neighbours_8dir(Position neighbour_array[8], size_t cost_array[8],
return cur;
}
+unsigned int neighbours_8dir_wraparound(Position neighbour_array[8], size_t cost_array[8], Position pos, size_t width, size_t height, \
+ char **visited, size_t **costs) {
+ (void) neighbour_array, (void) cost_array, (void) pos, (void) width, (void) height, (void) visited, (void) costs;
+ todo();
+}
+
Map rbt_maze_map(size_t width, size_t height, unsigned int seed) {
size_t map_width = width * 2 - 1,
map_height = height * 2 - 1;