diff options
author | Darshan Shaligram <dshaligram@users.sourceforge.net> | 2010-01-07 10:53:37 +0530 |
---|---|---|
committer | Darshan Shaligram <dshaligram@users.sourceforge.net> | 2010-01-07 10:53:37 +0530 |
commit | f8419c6ec131cedd6b2bcb7ffb3ba95c9448d6ac (patch) | |
tree | 60cad6f252a23c858f886f0c9a66cbc745692764 /crawl-ref/source/test | |
parent | 9dc168e1b56f681ecb8d806048fa649129207c9b (diff) | |
download | crawl-ref-f8419c6ec131cedd6b2bcb7ffb3ba95c9448d6ac.tar.gz crawl-ref-f8419c6ec131cedd6b2bcb7ffb3ba95c9448d6ac.zip |
Another Snake:$ rune test case, this time moving down the dungeon and generating all intermediate levels from D:1 to Snake:$ before checking for the rune.
Diffstat (limited to 'crawl-ref/source/test')
-rw-r--r-- | crawl-ref/source/test/snake-rune.lua | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/crawl-ref/source/test/snake-rune.lua b/crawl-ref/source/test/snake-rune.lua new file mode 100644 index 0000000000..56ea8b8273 --- /dev/null +++ b/crawl-ref/source/test/snake-rune.lua @@ -0,0 +1,66 @@ +local niters = 500 +local current_iter = 0 + +local branch_entrance_feats = { + { dgn.fnum("enter_lair"), "Lair:1" }, + { dgn.fnum("enter_snake_pit"), "Snake:1" } +} + +local junk_feat_fn = dgn.feature_set_fn("rock_wall", "floor", "stone_wall") +local down_stair_fn = dgn.feature_set_fn("stone_stairs_down_i", + "stone_stairs_down_ii", + "stone_stairs_down_iii") + +local function thing_exists_fn(thing) + return function() + return test.level_contains_item(thing) + end +end + +local function visit_branch_end_from(start, stair_places, final_predicate) + while true do + crawl.mesclr() + crawl.mpr("Visiting (" .. current_iter .. ") " .. start) + debug.goto_place(start) + + dgn.reset_level() + debug.generate_level() + + local downstairs = { } + for y = 1, dgn.GYM - 2 do + for x = 1, dgn.GXM - 2 do + local dfeat = dgn.grid(x, y) + if not junk_feat_fn(dfeat) then + for _, place in ipairs(stair_places) do + if dfeat == place[1] then + return visit_branch_end_from(place[2], stair_places, + final_predicate) + end + end + + if down_stair_fn(dfeat) then + table.insert(downstairs, dgn.point(x, y)) + end + end + end + end + + if #downstairs > 0 then + local _, _, branch, depth = string.find(start, "(%w+):(%d+)") + start = branch .. ":" .. (tonumber(depth) + 1) + else + test.map_assert(final_predicate(), + "Place " .. start .. " does not satisfy predicate") + return + end + end +end + +for i = 1, niters do + crawl.mpr("Visiting Snake:$ the hard way") + current_iter = i + debug.flush_map_memory() + visit_branch_end_from("D:1", + branch_entrance_feats, + thing_exists_fn("serpentine rune")) +end
\ No newline at end of file |