qoala / InvisibleInc-CommunityBugFixes

1 stars 0 forks source link

Recalculate guard paths more frequently. #6

Open qoala opened 4 years ago

qoala commented 4 years ago

When guards decide their paths for the next turn, they may deviate from the most direct route to move around another guard. If that other guard changes their mind or is otherwise disturbed, the first guard will now be pathing around an obstruction that never exists.

Extra credit A: Guards sometimes step around soft-cover orthogonally to allow ambush when an agent is in the diagonal destination tile. This also occasionally happens around doorways. Guards shouldn't step orthogonally for these cases when the agent is no longer there.

Extra credit B: Guards sometimes step around another guard that doesn't even reach the obstruction point this turn. Possibly because that guard gets re-pathed during a later step in evaluation?

qoala commented 4 years ago

Extra credit C: When sprinting near guards (and some other distractions), the guard's observed/TAGged path doesn't continue updating past the initial destination, even though the investigation point continues to follow the agent. The guard paths correctly on their turn, but the prediction is wrong. Unclear if this also leads to incorrect reservations (and other guards' detours)

qoala commented 4 years ago

Some buggy findings from dissecting the pather code (still in progress).

qoala commented 4 years ago
Case study: Guard detours around another guard that moves later https://clips.twitch.tv/FuriousTangibleDugongOSkomodo The unalerted alarm 4 guard "B" detours around a space from the alerted guard "A"'s path. However the unalerted guard ends up moving first. No one ends up in his way when he ends up moving, so he completes his path. Then the alerted guard is able to proceed without waiting. The space in question is 2 tiles in from the door. In an optimal path, both guards reach this tile on their 4th "step". Reconstruction: * Guard "A" reserves a direct path towards his hunt point * Guard "B" reserves a path towards his patrol point, including a detour around A at t=4 * When prioritizing the paths, B gets sorted ahead of A, because the tail end of A's path includes cells that B had to move through first (whereas B goes in a different direction after he passes their intersection point) * Because their order was swapped, both B & A's paths got recalculated in that order, one at a time. Since A's path was still reserved, B couldn't get a more direct path. The paths were unchanged. (I'm not yet sure if the recalculated paths in Pather:prioritisePaths is able to change who performs a detour in other situations) * On the guard turn, B moves first and is able to complete the patrol. The detour looks silly, because noone is there. * Then, A moves. At his t=4, it was possible for him to wait there and let B move, but because B is already gone, A no longer visibly pauses and completes his route. This detour comes from the pather using a mock simultaneity that isn't used for the actual movement (guards end up detouring when they'd intersect if they all simultaneously moved 1 timestep at a time). If Tony had enough AP to observe both guards, their paths would've appeared reasonable, because we accept guards detouring around path intersections, especially head-on collisions. It only looked weird once we reached the guard turn and B moved before A.
Conclusion: out of scope I'm trying to solve "guard detours around a space that no other guard has entered/will enter during the same turn (if all guards completed their predicted paths without interruption)" and "observed guard path does not match what actually happens". Not completely rework the pather to produce drastically different different results (like the above example, there's a lot of cases where no detours are needed if we spend more cycles reordering and recalculating guard paths to an optimal solution. But this would require completely different pathing logic that might behave differently in cases it can't improve) https://discordapp.com/channels/313015356052471828/313015598789427202/738610728277114913
qoala commented 4 years ago

Additional consequence of the 11 timestep reservations: Guards may end their turn with 1 AP left if the next step on their optimal route is a diagonal step.

This appears natural to the player, so any fix should leave this behavior in place.

Truncating pathing in the astar handler to the units AP would cause it to value getting as close to the goal as possible (and spend that 1AP with an orthogonal step in the most common layout). Might need to let the astar handler plan beyond the unit's AP, then truncate the path before passing it to reservePath

qoala commented 4 years ago
Case study: Guard detours around an extended path reservation https://clips.twitch.tv/SpinelessArtisticAyeayeResidentSleeper Two interesting things here: 1) The alarm 4 guard's investigation point is at t=11 on the CFO's fleeing path. So the guard steps away to allow this reserved space and is unable to step back and investigate this turn. (The pather highly values reaching the investigation point, so he steps on even though he won't be able to return once he steps out) This is finding 2, from above. 2) The CFO's reserved path includes a cell that another guard will have previously stepped through (the investigation point). To ensure that cell is vacated first, the CFO gets bumped to later in the guard turn order, so the elite security has already moved and doesn't see Tony. https://discordapp.com/channels/313015356052471828/313015598789427202/738690542627454976

Conclusion: Example of finding 2, which is in scope for fixing.