With some help from chat I sorted out how to randomize rooms without overlap.

This commit is contained in:
Zed A. Shaw 2026-03-08 03:28:49 -04:00
parent 47c0d4a5f0
commit fb41c153c1
6 changed files with 126 additions and 52 deletions

View file

@ -16,25 +16,31 @@ TEST_CASE("hunt-and-kill", "[mazes]") {
maze.hunt_and_kill();
// maze.dump("BASIC MAZE");
maze.randomize_rooms();
maze.randomize_rooms(ROOM_SIZE);
maze.hunt_and_kill();
maze.dump("ROOM MAZE");
// maze.dump("ROOM MAZE");
REQUIRE(map.$dead_ends.size() > 0);
REQUIRE(map.$rooms.size() > 0);
}
TEST_CASE("hunt-and-kill box", "[mazes]") {
Map map(21, 21);
maze::Builder maze(map);
for(int i = 5; i < 10000; i++) {
Map map((i / 20) + 20, (i / 20) + 20);
maze::Builder maze(map);
maze.inner_box(5, 4);
maze.hunt_and_kill();
maze.open_box(5, 4);
maze.hunt_and_kill();
maze.randomize_rooms(ROOM_SIZE+1);
maze.clear();
maze.dump("INNER BOX");
maze.inner_box(6, 3);
maze.hunt_and_kill();
maze.open_box(6);
REQUIRE(maze.$rooms.size() == 0);
if(maze.$rooms.size() == 0) {
maze.dump("NO ROOMS");
}
}
}
TEST_CASE("hunt-and-kill ring", "[mazes]") {
@ -75,15 +81,17 @@ TEST_CASE("hunt-and-kill no-dead-ends", "[mazes]") {
}
TEST_CASE("hunt-and-kill too much", "[mazes]") {
Map map(21, 21);
maze::Builder maze(map);
for(int i = 20; i < 10000; i++) {
Map map((i / 20) + 20, (i / 20) + 20);
maze::Builder maze(map);
maze.hunt_and_kill();
maze.randomize_rooms();
maze.init();
maze.inner_donut(4, 2);
maze.divide({3,3}, {19,18});
maze.hunt_and_kill();
maze.hunt_and_kill();
maze.randomize_rooms(ROOM_SIZE);
maze.clear();
maze.inner_donut(4, 2);
maze.divide({3,3}, {15,16});
maze.hunt_and_kill();
// maze.dump("COMBINED");
// maze.dump("COMBINED");
}
}