HotColdSolver: Add same-temperature solution narrowing

The hot-cold solver previously was unable to perform narrowing if given
a temperature change of "SAME", leading to less-than-optimal results
when a number of otherwise-possible solutions could be removed from the
possible results by inferring that since they would have yielded a
"COLDER" or "WARMER" temperature change. This commit removes possible
solutions which are absolutely closer or farther from the previous
tested location.

One pre-exisitng test needed to be updated to pass with this change, as
it expected results to be narrowed more slowly than they now are. In
addition, a minimal test case with only two starting locations has been
added to demonstrate this change is working correctly.
This commit is contained in:
Jordan Atwood
2020-02-02 15:46:50 -08:00
parent 6797132442
commit 73d37c061b
2 changed files with 27 additions and 6 deletions

View File

@@ -102,8 +102,10 @@ public class HotColdSolver
possibleLocations.removeIf(entry -> isFirstPointCloserRect(lastWorldPoint, worldPoint, entry.getRect()));
break;
case SAME:
// I couldn't figure out a clean implementation for this case
// not necessary for quickly determining final location
// eliminate spots which are absolutely colder or warmer (as they would not yield a SAME temperature change)
possibleLocations.removeIf(entry ->
isFirstPointCloserRect(worldPoint, lastWorldPoint, entry.getRect())
|| isFirstPointCloserRect(lastWorldPoint, worldPoint, entry.getRect()));
}
}