-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Path finding does not prefer friendly territory #4477
Comments
Could you provide a Screenshot? |
@RoiEXLab I'm fairly sure this is referring to route finding not prioritizing friendly over enemy owned territories for non-combat move. Here is a save game where you can try moving the train from Eastern Germany to Hungary Slovakia or Austria where both moves are legal through Poland but route finding tries to move through enemy owned Bohemia: There is also another thing that route finding doesn't consider which is unitsRequiredToMove (rails) in TWW. Both of these are on my list of things to improve so I can try to take a swing at this. |
@ron-murhammer If it's just preffering friendly territories over enemy territories with the same total distance then just sorting the neighbour territory list (friendly before enemy) before adding to the queue might already be enough already. |
@RoiEXLab Yeah, its potentially both though when the distance is equal is the more common scenario and much easier to address. If equal distance options at least consider territory ownership and rails that would be a good start. |
@sumpfralle Ok, thanks for the clarification. That situation is the more complex one as it then leads to the question of if I would try to move an inf instead of a truck over that route should it show 2 moves over enemy territory like it does in your screenshot or 3 moves over friendly territory. In other words, should you only consider prioritizing longer distances if the unit has enough movement to make the move in the current turn. |
I could imagine, that the case of source and target being friendly territories indicate under all circumstances (for combat moves as well as for non-combat moves), that the unit needs to move over friendly territory only. |
So I took an initial pass to improve route finding for equal distance options: #4498 I'll leave this open for now to further consider comparing non-equal distance options. |
What does "equal distance option" mean? I understand that this means that it may give a possible path that is not actually the shortest possible one. Other than this, will it always work for the case of having a 3 moves possible path over a 2 moves impossible one and, if so, will it always give a possible path, if anyone exists? |
Regarding what said in the linked pull, "consider friendly" is not fully covered by looking for "not enemy owned". A territory is also hostile (not friendly) if it has hostile units in it, that is usually the case of the sea zones (not being territories), but it may also matter for passable land territories having units belonging to another player you are at war with. Has this been taken into account, or the matter is now limited to ownership (thus totally or mostly irrelevant for sea units). Regarding the ownership, I wonder if these matters have been taken into considerations too:
|
By equal-distance option we're referring to the case, where there are multiple paths to a territory with the same amount of paths in between them, with the difference that some paths cross enemy territory while others don't. In this case it's trivial to prefer paths that don't cross enemy territory by trying to find a path through friendly territory first, with the same rules as before. However it's not trivial to create an algorithm that can guarantee to take a path through exclusive friendly territory if one exists for the maximum distance, potentially having to use a slightly longer path. So we're not talking about what is friendly territory, instead about what could be done if we knew that without completely killing performance and how a friendly route should be valued over the shortest route. |
@Cernelius As @RoiEXLab describes, the logic is only currently looking to prioritize between route options that have the same number of territories so it would never prefer a longer route having only friendly territories over a shorter route including enemy territories. Of the list of options you have, everything but 5 is already considered (6 only to some extent). Generally route finding works the following way (this is somewhat simplified):
Example: My advice would be to test the latest pre-release and see if you have certain scenarios where route finding could be improved. |
@sumpfralle The latest pre-release should address improving the route finding scenario you provided and many other similar ones. |
@ron-murhammer: thank you! I am just trying it :) |
Engine version
1.10.13405
My Operating System
Debian sid
Map name
Total War: December 1941
Can you describe how to trigger the error? (eg: what sequence of actions will recreate it?)
Try to move a unit with three movement points to a friendly territory, that can be reached within one move.
The shortest path to the target territory leads through one enemy territory (both the source and the target are neighbors of this enemy territory). The path selection prefers the path over the enemy territory (in a non-combat move).
Instead of this error, what should have happened?
The path over non-friendly territory should not be considered (especially not in a non-combat move).
UPDATES
The text was updated successfully, but these errors were encountered: