Skip to content
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

Reworked groundwar pathfinding #1102

Merged
merged 1 commit into from
Nov 8, 2023

Conversation

hemoridos
Copy link
Contributor

@hemoridos hemoridos commented Nov 8, 2023

Reworked the groundwar pathfinding. Did not touch much the overall infrastructure and AI logic. It mostly changes how passability checks are made and re-pathing strategy.

Some issues fixed:

  • Unit location does not snap to the correct cell for pathfinding when moving diagonally in a horizontal line.
  • Sometimes direct move orders get overwritten by attack orders that come from guard mode
  • Minor things I might have forgot to note down as there was a lot of trial and error involved.

Non exhaustive list of changes:

  • Replaced yielding with tile reservation and more aggressive re-pathing.
    Tile reservation is used instead of collision detection. This avoids issues that could come from fractional location coordinates, where multiple units might occupy the same node for pathing purposes. A tile is reserved by a unit as it starts its movement into it. The reservation is cleared when it arrives in the target cell.
  • diagonal movement is only prohibited if the top/bottom/left/right cells are permanently impassable. This the same as in the original. Also makes group movement pathing much cleaner,
  • Pathing requests are now stored in a LinkedHashMap for queing and discarding redundant requests of the same unit. This allows for more aggressive re-pathing requests without flooding the pathing queue and makes sure everyone gets their turn.
  • do occasional re-pathing between cells. Rate is currently 1/10 chance when between movement steps. Seems to work OK.
  • blocking objects considered temporary and thus ignored are:
    • enemy units in case of attack move(same as before)
    • friendly units in motion (fractional location or in rotation sequence)
    • inMotionPlanning no longer used
  • Group move order now gives each selected unit a destination location around the initially ordered location based on it's relative location within the group. This helps to avoid competing for the same destination location and preventing units moving in a single file. Attack move remained the same with a single destination, only they pile up a bit slower if they arrive at that destination.
  • attacking units re-path only if their target moves out of their maxRange relative to the original path destination.
  • If a unit can't find a path try again x times before giving up.
  • Treat paths of length 1 as empty as the first node is the one under the unit
  • Readjust goal location if original goal is blocked by a unit standing still
  • Merge pathing logic not needed as now all re-paths happen in stable(roundNum,roundNum) positions
  • changed how commands are shown in debug mode and added some extra information about tiles that are taken ore reserved by a unit.

Side note:

  • Removed the GroundWarManager from planet object as it is currently not used. What should be do with that?

Example videos:
https://drive.google.com/file/d/1Bd2k24DwUuamReztlFiDN7TmdGroS_HL/view?usp=drive_link
https://drive.google.com/file/d/1uS8y2frbkkevi6M51F4Krti80pg5hYrs/view?usp=drive_link

@hemoridos
Copy link
Contributor Author

In larger battles there is a slight hit to performance as there now more units actively moving around the map.

@akarnokd akarnokd merged commit 09b04fd into akarnokd:master Nov 8, 2023
@hemoridos hemoridos deleted the groundwar_pathing branch November 16, 2023 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants