You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
120 lines
2.5 KiB
120 lines
2.5 KiB
#include <catch2/catch_test_macros.hpp>
|
|
#include <fmt/core.h>
|
|
#include <string>
|
|
#include "matrix.hpp"
|
|
#include "rand.hpp"
|
|
#include "constants.hpp"
|
|
#include "maze.hpp"
|
|
|
|
using std::string;
|
|
using matrix::Matrix;
|
|
|
|
|
|
TEST_CASE("hunt-and-kill", "[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);
|
|
matrix::dump("BASIC MAZE", map);
|
|
|
|
maze::randomize_rooms(rooms, dead_ends);
|
|
maze::hunt_and_kill(map, rooms, dead_ends);
|
|
|
|
for(auto& room : rooms) {
|
|
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 box", "[mazes]") {
|
|
auto map = matrix::make(21, 21);
|
|
std::vector<Room> rooms;
|
|
std::vector<Point> dead_ends;
|
|
|
|
maze::init(map);
|
|
maze::inner_box(map, 5, 3);
|
|
maze::hunt_and_kill(map, rooms, dead_ends);
|
|
|
|
for(auto at : dead_ends) {
|
|
map[at.y][at.x]=32;
|
|
}
|
|
matrix::dump("INNER BOX", map);
|
|
|
|
REQUIRE(rooms.size() == 0);
|
|
}
|
|
|
|
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_donut(map, 5.5, 3.5);
|
|
maze::hunt_and_kill(map, rooms, dead_ends);
|
|
|
|
for(auto at : dead_ends) {
|
|
map[at.y][at.x]=32;
|
|
}
|
|
matrix::dump("INNER RING", 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);
|
|
|
|
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);
|
|
|
|
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_donut(map, 4, 2);
|
|
maze::divide(map, {3,3}, {19,18});
|
|
auto copy = map;
|
|
|
|
maze::hunt_and_kill(copy, rooms, dead_ends);
|
|
|
|
map = copy;
|
|
maze::randomize_rooms(rooms, dead_ends);
|
|
maze::hunt_and_kill(map, rooms, dead_ends);
|
|
|
|
matrix::dump("COMBINED", map);
|
|
}
|
|
|