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:
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user