Better map generation and a test that re-rolls maps that aren't valid to figure out the stats of map gen failures.

This commit is contained in:
Zed A. Shaw 2026-03-11 12:31:51 -04:00
parent 8090251a71
commit f85ae8a6c6
12 changed files with 131 additions and 76 deletions

View file

@ -5,8 +5,9 @@
#include "algos/rand.hpp"
#include "constants.hpp"
#include "algos/maze.hpp"
#include "algos/stats.hpp"
#define DUMP 0
#define DUMP 1
using std::string;
using matrix::Matrix;
@ -102,21 +103,36 @@ TEST_CASE("hunt-and-kill too much", "[mazes]") {
}
TEST_CASE("hunt-and-kill validator", "[mazes]") {
Map map(33, 33);
maze::Builder maze(map);
bool valid = true;
Stats mofm;
maze.hunt_and_kill();
maze.clear();
maze.inner_box(6, 4);
maze.randomize_rooms(ROOM_SIZE);
maze.hunt_and_kill();
maze.open_box(6);
maze.make_doors();
maze.enclose();
for(int i = 0; i < 100; i++) {
Stats door_prob;
bool valid = maze.validate();
do {
Map map(33, 33);
maze::Builder maze(map);
maze.dump("VALIDATED");
maze.hunt_and_kill();
maze.clear();
maze.inner_box(6, 4);
maze.randomize_rooms(ROOM_SIZE);
maze.hunt_and_kill();
maze.open_box(6);
maze.make_doors();
maze.enclose();
REQUIRE(valid == true);
valid = maze.validate();
if(valid && i == 99) {
maze.dump("VALIDATED");
}
door_prob.sample(valid);
} while(!valid);
mofm.sample(door_prob.mean());
}
mofm.dump();
REQUIRE(mofm.mean() > 0.20);
}