Playing with maze gen again.

This commit is contained in:
Zed A. Shaw 2025-05-20 03:19:58 -04:00
parent c97648ab3a
commit 33cd490ed3
8 changed files with 164 additions and 36 deletions

View file

@ -10,16 +10,94 @@ using std::string;
using matrix::Matrix;
TEST_CASE("hunt-and-kill", "[maze-gen]") {
TEST_CASE("hunt-and-kill", "[mazes]") {
auto map = matrix::make(21, 21);
std::vector<Room> rooms;
std::vector<Point> dead_ends;
maze::hunt_and_kill(map, rooms, dead_ends);
matrix::dump("MAZE?", map);
matrix::dump("BASIC MAZE", map);
maze::randomize_rooms(rooms, dead_ends);
maze::hunt_and_kill(map, rooms, dead_ends);
for(auto& room : rooms) {
fmt::println("room: {},{}; {},{}",
room.x, room.y, room.width, room.height);
for(matrix::box it{map, room.x, room.y, room.width};
it.next();)
{
map[it.y][it.x] = WALL_PATH_LIMIT;
}
}
matrix::dump("MAZE WITH ROOMS", map);
}
TEST_CASE("hunt-and-kill ring", "[mazes]") {
auto map = matrix::make(21, 21);
std::vector<Room> rooms;
std::vector<Point> dead_ends;
maze::init(map);
maze::inner_ring(map, 5, 2);
maze::hunt_and_kill(map, rooms, dead_ends, false);
for(auto at : dead_ends) {
map[at.y][at.x]=32;
}
matrix::dump("RING MAZE", map);
REQUIRE(rooms.size() == 0);
}
TEST_CASE("hunt-and-kill fissure", "[mazes]") {
auto map = matrix::make(21, 21);
std::vector<Room> rooms;
std::vector<Point> dead_ends;
maze::init(map);
maze::divide(map, {3,3}, {19,18});
maze::hunt_and_kill(map, rooms, dead_ends, false);
for(auto at : dead_ends) {
map[at.y][at.x]=32;
}
matrix::dump("FISSURE MAZE", map);
REQUIRE(rooms.size() == 0);
}
TEST_CASE("hunt-and-kill no-dead-ends", "[mazes]") {
auto map = matrix::make(21, 21);
std::vector<Room> rooms;
std::vector<Point> dead_ends;
maze::init(map);
maze::hunt_and_kill(map, rooms, dead_ends, false);
maze::remove_dead_ends(map, dead_ends);
matrix::dump("NO DEAD ENDS", map);
}
TEST_CASE("hunt-and-kill too much", "[mazes]") {
auto map = matrix::make(21, 21);
std::vector<Room> rooms;
std::vector<Point> dead_ends;
maze::init(map);
maze::inner_ring(map, 4, 2);
maze::divide(map, {3,3}, {19,18});
auto copy = map;
maze::hunt_and_kill(copy, rooms, dead_ends, false);
map = copy;
maze::randomize_rooms(rooms, dead_ends);
maze::hunt_and_kill(map, rooms, dead_ends, false);
matrix::dump("NO DEAD ENDS", map);
}