mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
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:
parent
ba6d1bce60
commit
b681ad79ce
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user