From ba06b43178984f75b804f39732570b35e7900e7e Mon Sep 17 00:00:00 2001 From: zelgadis Date: Sun, 23 Dec 2007 03:56:06 +0000 Subject: Fixed anti-zigzag angle-bisection logic bug, reducint the worst case scenario increase in auto-explroe turns from 20% to 13%. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3110 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/travel.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'crawl-ref/source/travel.cc') diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 07efdd4afe..8cbbc9740f 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -894,18 +894,22 @@ static void explore_find_target_square() } // If the two previous travel moves are perpendicular to each - // other. + // other... if (prev_travel_moves[0] != -1 && prev_travel_moves[1] != -1 && (abs(prev_travel_moves[1] - prev_travel_moves[0]) % 4) == 2) { + ASSERT(anti_zigzag_dir == -1); + // Try moving along the line that bisects the right angle. - if (abs(prev_travel_moves[0] - prev_travel_moves[1]) == 6) - anti_zigzag_dir = 0; + if ((abs(prev_travel_moves[0] - prev_travel_moves[1]) == 6) + && (prev_travel_moves[0] + prev_travel_moves[1] == 8)) + { + anti_zigzag_dir = 0; + } else anti_zigzag_dir = std::min(prev_travel_moves[0], prev_travel_moves[1]) + 1; - } // anti_zigzag_dir might have just been set, or might have @@ -938,7 +942,6 @@ static void explore_find_target_square() whereto.x, whereto.y) <= 5 && distance(target.x, target.y, whereto.x, whereto.y) <= 34) - //&& t_dist - w_dist <= 14) { set_target_square(target); return; -- cgit v1.2.3-54-g00ecf