Maze scripts now work reliably.

This commit is contained in:
Zed A. Shaw 2026-03-13 10:41:42 -04:00
parent c615f4fc1e
commit 9001af214a
3 changed files with 27 additions and 22 deletions

View file

@ -152,24 +152,30 @@ TEST_CASE("hunt-and-kill validator", "[mazes]") {
TEST_CASE("hunt-and-kill scripting", "[mazes]") {
using namespace nlohmann::literals;
auto script = R"(
[
{"action": "hunt_and_kill"},
{"action": "clear"},
{"action": "inner_box", "data": [6, 4]},
{"action": "randomize_rooms", "data": [4]},
{"action": "divide", "data": [3, 3, 10, 10]},
{"action": "inner_donut", "data": [5.5,4.5]},
{"action": "hunt_and_kill"},
{"action": "open_box", "data": [6]},
{"action": "remove_dead_ends"},
{"action": "make_doors"}
]
)"_json;
// go up by 2 to keep odd
for(int i = 0; i < 20; i+=2) {
auto script = R"(
[
{"action": "hunt_and_kill"},
{"action": "clear"},
{"action": "inner_box", "data": [6, 4]},
{"action": "randomize_rooms", "data": [4]},
{"action": "divide", "data": [3, 3, 10, 10]},
{"action": "inner_donut", "data": [5.5,4.5]},
{"action": "hunt_and_kill"},
{"action": "open_box", "data": [6]},
{"action": "remove_dead_ends"},
{"action": "make_doors"}
]
)"_json;
Map map(23+i, 23+i);
auto [maze, valid] = maze::script(map, script);
Map map(33, 33);
auto [maze, valid] = maze::script(map, script);
maze.dump("SCRIPTED");
REQUIRE(valid == true);
if(valid) {
REQUIRE(maze.validate() == true);
}
if(DUMP) maze.dump(valid ? "SCRIPTED" : "SCRIPTED FAIL!");
}
}