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

Performance upgrade, less CPU usage, code refactor, optimization of A* algorithm, an attempt of fixing character getting stuck on "Hidden Stash" object at Chaos Sanctuary. #650

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

AquaRush
Copy link
Contributor

astar.go:

  • Code refactor, proper Collision Handling in A* algorithm, grid preprocessing fixes, cost calculations for tiles/collisions, performance upgrade.

path_finder.go:

  • Code refactor, proper collision detection and avoidance, valid pathfinding (even across area boundaries), performance upgrade.

path.go:

  • Code refactor, added cache and cache efficiency (area-specific cache keys prevent cross-area conflicts), LRU cache prevents memory issues, optimized A* with results up to 20-30% CPU reduction.

utils.go:

  • Code refactor, preserved caching, optimization.

Code refactor, preserved caching, optimization.
Code refactor, proper collision detection and avoidance, valid pathfinding (even across area boundaries), performance upgrade.
Code refactor, added cache and cache efficiency (area-specific cache keys prevent cross-area conflicts), LRU cache prevents memory issues, optimized A* with results up to 20-30% CPU reduction.
Code refactor, proper Collision Handling in A* algorithm, Grid preprocessing fixes, Cost calculations for tiles/collisions, performance upgrade.
Add a check for FindNearbyWalkablePosition to to prevent issues with pather in certain areas, thanks to elb for the fix :)
@AquaRush
Copy link
Contributor Author

There was an issue with the pather which was fixed by @elobo91 in move.go :)

`findNearbyWalkablePosition` -> `FindNearbyWalkablePosition`
Accidental removal of ctx.RefreshGameData()
Possible fix of bot getting stuck on "Hidden Stash" object at Chaos.
@AquaRush
Copy link
Contributor Author

Updated path_finder.go with a small code of checking the "Hidden Stash" object at Chaos, tested on 3 characters, all of them ignored the object at the entrance of Chaos a few games in a row, if "Hidden Stash" was near mobs that had to be killed, character stayed for a second at the object but did not try interact with it or freeze, it continued afterwards.

@AquaRush AquaRush changed the title Performance upgrade, less CPU usage, code refactor, optimization of A* algorithm. Performance upgrade, less CPU usage, code refactor, optimization of A* algorithm, an attempt of fixing character getting stuck on "Hidden Stash" object at Chaos Sanctuary. Jan 30, 2025
@braccali1
Copy link
Contributor

On my first test of this PR, nova sorc got stuck on a stash just west of the star in CS. It didn't seem to get stuck when traveling to Viz, but on the way to seis. Buffing broke the char being stuck. There may have been an attack that caused the char to be right next to the stash, thus attacking may need a similar pathing check like this.

@AquaRush
Copy link
Contributor Author

AquaRush commented Jan 31, 2025

@braccali1 that is strange because I never had similar issues with a lot of games in a row running 3 clients, could you tell me what exactly your character bugged on, I need name of the object that the character bugged, did it also try to cast anything or click on it or just stand on it without doing anything?

EDIT:
There seems to be an issue with "Hidden Stashes" not being ignored properly, seems like the latest commit doesn't work if there's a mob around it tries to read the object of "Hidden Stashes" and attack at the same time causing a loop, I will look into it and test it out, if I manage to fix this, I will push an update commit.

@braccali1
Copy link
Contributor

If I see it happen again I will try to grab the object id. The character was attempting to teleport over and over, but was stuck behind the stash.

Also getting multiple attempts to teleport when already standing right next to a seal.

Prevent pathfinding near hidden stashes by creating a 5x5 non-walkable zone around hidden stashes, forcing paths to detour.
Block interactions and improve safety checks, completely skips hidden stash interactions, moves to walkable positions before interacting with objects.
Improve movement reliability by avoiding getting stuck on blocked objects, maintains original timeout/retry logic, fixes "undefined variable" errors.
@AquaRush
Copy link
Contributor Author

@braccali1 please try out the latest changes and let me know if any issues occur, thank you.

Re-added `ctx.RefreshGameData()` & modified // Exint on timeout modification check for proper Hidden Stash ignore @ Chaos.
Re-add comments from original source.
@jightya
Copy link

jightya commented Feb 3, 2025

Is there any reason this doesnt get merged?

@elobo91
Copy link
Contributor

elobo91 commented Feb 3, 2025

Is there any reason this doesnt get merged?

It has to be reviewed by hectorgimenez . its also not totally ready from what i reviewed . It could have been merged when null marked it for review at 9bb1cf8

@jightya
Copy link

jightya commented Feb 4, 2025

Is there any reason this doesnt get merged?

It has to be reviewed by hectorgimenez . its also not totally ready from what i reviewed . It could have been merged when null marked it for review at 9bb1cf8

Alright, because i like the sound of cpu usage optimizations :P

Re-add comments, minor code refactor.
Add comments of logic.
Add comments.
Add comments.
Revert some changes.
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.

4 participants