diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-10-14 09:40:47 +0200 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-10-14 12:03:30 +0200 |
commit | 97ac9424c4676f6dee9c9e2e8fd7cec93b5e37ce (patch) | |
tree | 1a282c045dba05c5b84123e1f50cdf2c9ff02683 /crawl-ref/source/test/findray.lua | |
parent | 832acfd1812519980c09122f380e8aca07e118e2 (diff) | |
download | crawl-ref-97ac9424c4676f6dee9c9e2e8fd7cec93b5e37ce.tar.gz crawl-ref-97ac9424c4676f6dee9c9e2e8fd7cec93b5e37ce.zip |
Correct findray test.
Now only targets cells that are not blocked by transparent walls
etc. find_ray can't currently check for real visibility.
Diffstat (limited to 'crawl-ref/source/test/findray.lua')
-rw-r--r-- | crawl-ref/source/test/findray.lua | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/crawl-ref/source/test/findray.lua b/crawl-ref/source/test/findray.lua index b98f23e5d4..72f9526f15 100644 --- a/crawl-ref/source/test/findray.lua +++ b/crawl-ref/source/test/findray.lua @@ -1,9 +1,9 @@ -- Check basic find_ray functionality. -local FAILMAP = 'losfail.map' +local FAILMAP = 'rayfail.map' local checks = 0 -local function test_losight_symmetry() +local function test_findray() -- Clear messages to prevent them accumulating and forcing a --more-- crawl.mesclr() -- Send the player to a random spot on the level. @@ -12,7 +12,6 @@ local function test_losight_symmetry() -- Forcibly redo LOS. you.losight() - checks = checks + 1 local you_x, you_y = you.pos() local you_p = dgn.point(you_x, you_y) @@ -21,7 +20,7 @@ local function test_losight_symmetry() for x = -8, 8 do if x ~= 0 or y ~= 0 then local px, py = x + you_x, y + you_y - if you.see_grid(px, py) then + if you.see_grid_no_trans(px, py) then table.insert(visible_spots, { px, py }) end end @@ -31,6 +30,7 @@ local function test_losight_symmetry() -- For each position in LOS, shoot a ray there -- and make sure it doesn't go through an opaque cell. for _, spot in ipairs(visible_spots) do + checks = checks + 1 local x, y = unpack(spot) local p = dgn.point(x, y) local ray = los.findray(you_x, you_y, x, y) @@ -38,7 +38,8 @@ local function test_losight_symmetry() dgn.grid(x, y, "floor_special") dgn.dbg_dump_map(FAILMAP) assert(false, "Can't find ray to " .. p .. - " although it's in view.") + " although it's in unobstructed view. (#" .. + checks .. ")") end local rx, ry = ray:pos() local ray_p = dgn.point(rx, ry) @@ -64,20 +65,20 @@ local function test_losight_symmetry() end end -local function run_los_tests(depth, nlevels, tests_per_level) +local function run_findray_tests(depth, nlevels, tests_per_level) local place = "D:" .. depth - crawl.mpr("Running LOS tests on " .. place) + crawl.mpr("Running find_ray 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_losight_symmetry() + test_findray() end end end for depth = 1, 27 do - run_los_tests(depth, 1, 10) + run_findray_tests(depth, 1, 10) end |