From d87a308f449bb959db24495e2a1dc307924bc8ae Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Thu, 8 Oct 2009 22:40:29 +0200 Subject: Split and correct grid_see_grid. There's now cell_see_cell which tests for visibility correctly, albeit slowly. That's only used for placing features in the abyss currently, but needs to be improved if it gets used more. The second function used in monster movement was left as is, but renamed to can_go_straight. This remains unreliable but probably serves its purpose. The grid_see_grid test is adapted to cell_see_cell; the grid_see_grid lua binding is now actually useful. Also reduce the number of tests in los_csc and los_symm. --- crawl-ref/source/test/los_csc.lua | 60 ++++++++++++++++++++++++++++++++++++++ crawl-ref/source/test/los_gsg.lua | 58 ------------------------------------ crawl-ref/source/test/los_symm.lua | 2 +- 3 files changed, 61 insertions(+), 59 deletions(-) create mode 100644 crawl-ref/source/test/los_csc.lua delete mode 100644 crawl-ref/source/test/los_gsg.lua (limited to 'crawl-ref/source/test') diff --git a/crawl-ref/source/test/los_csc.lua b/crawl-ref/source/test/los_csc.lua new file mode 100644 index 0000000000..499511a6c2 --- /dev/null +++ b/crawl-ref/source/test/los_csc.lua @@ -0,0 +1,60 @@ +-- Vet LOS for symmetry. + +local FAILMAP = 'losfail.map' +local checks = 0 + +local function test_cellseecell_symmetry() + -- Clear messages to prevent them accumulating and forcing a --more-- + crawl.mesclr() + -- Send the player to a random spot on the level. + you.random_teleport() + you.losight() + crawl.redraw_view() + + checks = checks + 1 + local you_x, you_y = you.pos() + + for y = -9, 9 do + for x = -9, 9 do + local px, py = x + you_x, y + you_y + if (x ~= 0 or y ~= 0) and dgn.in_bounds(px, py) then + local foreward = dgn.cell_see_cell(you_x, you_y, px, py) + local backward = dgn.cell_see_cell(px, py, you_x, you_y) + this_p = dgn.point(you_x, you_y) + other_p = dgn.point(px, py) + if not forward then + you.moveto(px, py) + local temp = this_p + this_p = other_p + other_p = temp + end + if (forward and backward) or (not forward and not backward) then + dgn.grid(other_p.x, other_p.y, "floor_special") + dgn.dbg_dump_map(FAILMAP) + assert(false, + "cell_see_cell asymmetry detected (iter #" .. checks .. "): " + .. this_p .. " sees " .. other_p .. ", but not vice versa." + .. " Map saved to " .. FAILMAP) + end + end + end + end +end + +local function run_los_tests(depth, nlevels, tests_per_level) + local place = "D:" .. depth + crawl.mpr("Running LOS tests on " .. place) + dgn.dbg_goto_place(place) + + for lev_i = 1, nlevels do + dgn.dbg_flush_map_memory() + dgn.dbg_generate_level() + for t_i = 1, tests_per_level do + test_cellseecell_symmetry() + end + end +end + +for depth = 1, 27 do + run_los_tests(depth, 1, 1) +end diff --git a/crawl-ref/source/test/los_gsg.lua b/crawl-ref/source/test/los_gsg.lua deleted file mode 100644 index 69b86d1da7..0000000000 --- a/crawl-ref/source/test/los_gsg.lua +++ /dev/null @@ -1,58 +0,0 @@ --- Vet LOS for symmetry. - -local FAILMAP = 'losfail.map' -local checks = 0 - -local function test_gridseegrid_symmetry() - -- Clear messages to prevent them accumulating and forcing a --more-- - crawl.mesclr() - -- Send the player to a random spot on the level. - you.random_teleport() - - checks = checks + 1 - local you_x, you_y = you.pos() - - for y = -9, 9 do - for x = -9, 9 do - local px, py = x + you_x, y + you_y - if (x ~= 0 or y ~= 0) and dgn.in_bounds(px, py) then - local foreward = dgn.grid_see_grid(you_x, you_y, px, py) - local backward = dgn.grid_see_grid(px, py, you_x, you_y) - this_p = dgn.point(you_x, you_y) - other_p = dgn.point(px, py) - if not forward then - you.moveto(px, py) - local temp = this_p - this_p = other_p - other_p = temp - end - if forward ~= backward then - dgn.grid(other_p.x, other_p.y, "floor_special") - dgn.dbg_dump_map(FAILMAP) - assert(false, - "grid_see_grid asymmetry detected (iter #" .. checks .. "): " - .. this_p .. " sees " .. other_p .. ", but not vice versa." - .. " Map saved to " .. FAILMAP) - end - end - end - end -end - -local function run_los_tests(depth, nlevels, tests_per_level) - local place = "D:" .. depth - crawl.mpr("Running LOS tests on " .. place) - dgn.dbg_goto_place(place) - - for lev_i = 1, nlevels do - dgn.dbg_flush_map_memory() - dgn.dbg_generate_level() - for t_i = 1, tests_per_level do - test_gridseegrid_symmetry() - end - end -end - -for depth = 1, 27 do - run_los_tests(depth, 1, 10) -end diff --git a/crawl-ref/source/test/los_symm.lua b/crawl-ref/source/test/los_symm.lua index beb809beee..43bce66928 100644 --- a/crawl-ref/source/test/los_symm.lua +++ b/crawl-ref/source/test/los_symm.lua @@ -63,5 +63,5 @@ local function run_los_tests(depth, nlevels, tests_per_level) end for depth = 1, 27 do - run_los_tests(depth, 1, 10) + run_los_tests(depth, 1, 3) end -- cgit v1.2.3-54-g00ecf