aliens

Author Topic: Pathfinding and kneeling  (Read 1432 times)

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 605
    • View Profile
Pathfinding and kneeling
« on: November 07, 2022, 12:29:12 pm »
I'm not sure where this belongs. I had a very specific issue in my AI that I also eventually fixed within the AI but it might belong to the path-finding.

The problem was the following: The AI mind-contolled one of my soldiers, used it to throw a grenade and then got stuck in an endless-loop.
The issue was that it wanted to move to a different location within _reachableTiles afterwards. It thought it could reach that tile because it didn't take into account that the soldier, who was kneeled before first has to stand up. Without standing up it's 7 TUs were enough to move there. My exit-condition is "Is the tile the soldier currently is at the same tile it wants to go." And this wasn't the case as it couldn't get there.

What I did to fix it was adding the cost to stand up to the TUs that need to be reserved. But that feels more like a work-around. But I also don't think it belongs directly into the path-finding as the cost for standing up isn't actually a part of the path either. In essence, if you are kneeling you could add the cost of standing up to the cost of getting to every node. (In the Dijkstra's algorithm that the base AI uses to determine the reachable tiles and my AI uses for all path-finding-purposes)

So basically I know how to fix it either way I'm just not sure what's the right place. For the base-AI it probably isn't that important. But if someone has an otherwise unexplainable endless-loop a kneeling mind-controlled soldier might probably be the reason.

I'm not sure what happens when you kneel a soldier and then click somewhere. If it's taken into account in this case. If it's also showing the wrong cost in this regard, then the issue exceeds AI.

Offline Yankes

  • Commander
  • *****
  • Posts: 3209
    • View Profile
Re: Pathfinding and kneeling
« Reply #1 on: November 07, 2022, 01:16:53 pm »
This is not suggestion but problem with code, this topic should be moved to "Programing" section.

For problem itself, kneeling affect every unit, aliens alike soldiers can kneel, only difference is that aliens by default do not do this.
This mean this bug will affect most of big mods that use this feature.

I added kneeling for AI couple moths ago, and up this point I do not recall bugs like this in normal AI.
I think proper place is check this outside of pathfinding as it job is count cost of move between two arbitrary points.
This mean limits (reserved) should include cost of getting up from kneeling and optionally knelling back when unit reach destination.

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 605
    • View Profile
Re: Pathfinding and kneeling
« Reply #2 on: November 07, 2022, 02:57:49 pm »
I do not recall bugs like this in normal AI.
I read the code of the normal AI in regards to that. It should theoretically be possible to happen but under some very specific circumstances.

When findFirePoint sets the action to BA_WALK it also uses the trick of setting action.number -= 1, which is requirement to cause the endless-loop in the first-place.
So theroethically if _attackAction.target is set to something that is reachable according to path-finding but actually isn't because the unit needs to first stand up, then this should cause that same issue.

Ah, nevermind. It uses _reachableWithAttack, not _reachable. Because of that it will reserve enough TU anyways. It just won't be able to attack afterwards, which isn't nearly as problematic as being caught in an endless-loop.