Fix heuristic to restart route in chase()

We had a random chance of restarting the route to avoid getting the
chaser stuck. This didn't work properly because the rerouting code was
only triggered if `self.route.is_none()` or if the target moved
significantly, and the random chance branch only set `bearing` to `None`.

This change sets `self.route = None` to trigger rerouting.
This commit is contained in:
Hugo Peixoto 2022-05-14 14:50:09 +01:00
parent ba6d1bce60
commit b681ad79ce

View File

@ -380,9 +380,10 @@ impl Chaser {
// theory this shouldn't happen, but in practice the world is full
// of unpredictable obstacles that are more than willing to mess up
// our day. TODO: Come up with a better heuristic for this
if (end_to_tgt > pos_to_tgt * 0.3 + 5.0 && complete)
|| thread_rng().gen::<f32>() < 0.001
{
if end_to_tgt > pos_to_tgt * 0.3 + 5.0 && complete {
None
} else if thread_rng().gen::<f32>() < 0.001 {
self.route = None;
None
} else {
self.route