Implements JPS (Jump Point Search) Pathfinding#56780
Merged
optimumtact merged 63 commits intotgstation:masterfrom Feb 22, 2021
Merged
Implements JPS (Jump Point Search) Pathfinding#56780optimumtact merged 63 commits intotgstation:masterfrom
optimumtact merged 63 commits intotgstation:masterfrom
Conversation
Timberpoes
pushed a commit
that referenced
this pull request
Mar 22, 2021
In #56780 I thought it'd be fine to change the get_path function to return null if there was no path found instead of an empty list, but apparently quite a lot of code in simple bots expects empty lists and freaks out if path is just null, causing simple bots to occasionally fail to respond to summoning even if a path is clearly found and briefly assigned This undoes that
|
Would it be okay with you if we were to port this to /vg/station? |
Contributor
|
Would it be okay with you if we were to port this to Goonstation? |
Contributor
Author
|
Sure but you're legally bound to say "ryll is cool" somewhere in there |
Member
|
BASED, HOLY SHIT pathfinding being expensive was unironically what held my botany animal caretaking PR back |
optimumtact
pushed a commit
to tgstation/rust-g
that referenced
this pull request
Sep 11, 2022
Returns the shortest path in a static node map. That is made for TGMC wich uses manually placed nodes for pathfinding. Benchmark : image That's the average number of path computed in one second, out of 30 runs with random nodes. Size of the node map is roughly 800 On average 32 times faster than tgmc a* implementation. Another possible comparison is with TG's JPS system, and according to the benchmark done here it's 7000 times faster (tgstation/tgstation#56780). Not exactly the same use cases though
Crossedfall
pushed a commit
to BeeStation/rust-g
that referenced
this pull request
Mar 11, 2023
* Updates the byond testing version to tgstation ver (tgstation#66) * runs cargo fmt (tgstation#63) * Sets the debug and test linux build to use all features (tgstation#67) Problem: PRs and all features aren't properly running created unit tests. Nor are they actually being fully compiled (only checked) on Linux. Solution: Only have the release builds that are distributed as artifacts run with the default features. This way, tests can cover all features. * Base64 encoding (tgstation#65) * Adds base64 encoding * Adds tests * Commented out import * Fixes the naming of variables * ...of course it was a typo * Update Cargo.toml Co-authored-by: William Wallace <me@wiox.me> * Clippy tweaks (tgstation#62) * this `else { if .. }` block can be collapsed * question mark operator is useless here * this call to `from_str_radix` can be replaced with a call to `str::parse` * equality checks against true are unnecessary * Revert "question mark operator is useless here" This reverts commit 01272c5. * Cargo update (tgstation#64) * updates cargo dependencies versions to latest * Fixes perlin noise generation to use an inclusive range * Update src/cellularnoise.rs Co-authored-by: William Wallace <me@wiox.me> * Updates cargo.lock Co-authored-by: William Wallace <me@wiox.me> * Basic version getter (tgstation#68) * Bump Version sto v0.4.8 * Setup cross compiling using the cross project (tgstation#70) * Make the url feature default (tgstation#71) Co-authored-by: Jared-Fogle <35135081+Jared-Fogle@users.noreply.github.com> * 0.4.9 * Runs cargo update (tgstation#72) most importantly git2, which made it error when trying to build on linux with the latest rust version * Stringify url_encode and decode input before sending it to Rust (tgstation#73) Co-authored-by: Jordan Brown <Cyberboss@users.noreply.github.com> * 0.4.10 * Add worley noise optional feature (tgstation#74) * worley_noise * a simple fix, forgot to ad dmsort as a necessary package * replaces .unwrap() with ? * forgot to save :cryingintoheavens: * IM SORRY I CANT USE ? IN CLOSURES * Completely reworks how the code works, massively optimizing it. Generation lost a tiny bit of it's fidelity but oh well, looks fantastic rn * one last change * tfw errors * makes the noise generate pretties noise * cargo fmt * Add TOML feature (tgstation#75) Adds rustg_read_toml_file, which takes a filepath and spits out the output after decoding (a list, probably). Uses the rust-toml lib * 0.5.0 Cargo updates * Adds TOTP generator to the hash feature (tgstation#76) * Adds TOTP generator to the hash feature * Updated TOTP based on requested changes, added a function that allow specification of a tolerance, also updated the hash.dm file to reflect the new functions * Remove debug print, convert offset output to be JSON, added a test * Added comments * Added some error handling * Improves error handling again * cargo fmt hash.rs * separate mod block for hash tests * Functions for more precise time measurement (tgstation#77) * fix linux ci by removing pkg-config requirement This isnt needed * Aho-Corasick string replacements to help clean up replaceText spam (tgstation#82) * Cleanups and additions for the Aho-Corasick replacement stuff (tgstation#83) * Fix clippy lints, Rustfmt, put both on CI, and update Cargo.lock (tgstation#85) Co-authored-by: Mothblocks <35135081+Jared-Fogle@users.noreply.github.com> * Adds Redis Pub/Sub integration (tgstation#80) dds the ability to connect to Redis, subscribe to messages and publish them as well. See here for example usage. The API, prefixed with rustg_redis_: connect(addr) - Connects to a Redis instance using the given address, for example redis://127.0.0.1/. Returns an empty string on success, returns the error otherwise. disconnect() - Closes the connection to Redis and stops the thread managing it. Call this before restarting or attempting to reconnect after an error. subscribe(channel) - Subscribes to a given channel and starts receiving messages from it. get_messages() - Returns all received messages as a JSON string, in the format of {"channel_1": ["msg1", "msg2", "msg3", ...], "channel_2": ["msg1", "msg2", "msg3", ...]}. Also includes errors, which appear on the channel "RUSTG_REDIS_ERROR_CHANNEL". publish(channel, message) - Publishes a message on the given channel. Remember to check the error channel every time you call get_messages(). If any occur, you need to call disconnect(), then connect() again, then resubscribe to desired channels. * fixes warning in redis (tgstation#88) * Fix clippy CI, format byond_fn (tgstation#89) * Adds alphabetical order tests for README.md, lib.rs and Cargo.toml (tgstation#84) Adds alphabetical order tests for README.md, lib.rs and Cargo.toml tgstation#84 Also renamed "non-default features" to "additional features" in Cargo.toml for consistency with readme updated the cargo.lock and ran rustfmt * Bump to 0.6.0 (tgstation#90) * Fixes redis dmsrc (tgstation#91) * Cleaner and saner http request parsing. (tgstation#93) * Add functions for seeking lines and getting line counts in functions (tgstation#95) dds rustg_file_get_line_count for getting the line count of a given filename, and rustg_file_seek_line for getting a specific line. These are useful as to not load the entire file into memory in DM, which is useful for very large files like dictionaries. * 0.7.0 (tgstation#96) * Adds a new type of noise: Discrete Batched Perlin-like Noise (DBP) (tgstation#99) * Updates WorleyNoise to be multi-threaded and faster (tgstation#102) Another noise algorithm updated in my streak, this time it's worleynoise, since i didn't know jack shit and i heavily abused Rc<> to acomplish my goals it was really shit. Now it is multi-threaded, blazing fast and really sexy lookin. NOTE: this update changes ABI of worley noise slightly. * Updates CellularNoise to be faster and multi-threaded (tgstation#101) Hello, I guess i'm on a streak. I reimplemented CAnoise to be multi-threaded and much faster as i removed a considerable amount of branches. No change to behaviour or ABI noted, it's just faster now. * toml2json now returns errors to byond (tgstation#98) Co-authored-by: ZeWaka <zewakagamer@gmail.com> * Updates cargo packages (tgstation#104) * 0.8.0 * Tiny README update * Small improvements for before 1.0 (tgstation#105) * 1.0.0 (tgstation#106) * Pallette Encoding Image Fix (tgstation#107) * Uploads rust_g.dm as an Actions Artifact (tgstation#108) * 1.0.1 * add note to README about not using the .so * Returns the TOML library to previous functionality (tgstation#112) * 1.0.2 * Clippy - unneeded returns (tgstation#114) * Add an a* pathfinder (tgstation#113) Returns the shortest path in a static node map. That is made for TGMC wich uses manually placed nodes for pathfinding. Benchmark : image That's the average number of path computed in one second, out of 30 runs with random nodes. Size of the node map is roughly 800 On average 32 times faster than tgmc a* implementation. Another possible comparison is with TG's JPS system, and according to the benchmark done here it's 7000 times faster (tgstation/tgstation#56780). Not exactly the same use cases though * Add rustg_toml_encode (tgstation#116) Add rustg_toml_encode * 1.1.0 * Fixes cellular noise not working for diff height and width values (tgstation#117) * Update README.md update readme with `pathfinder` feature and rust-analyzer note, re: tgstation#115 * Fix the `pathfinder` feature's loc in the README * Package debug symbols with rust-g (tgstation#119) * 515 Support (tgstation#121) * add a unix_timestamp extern (tgstation#122) Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com> * 1.2.0 * Remove useless features from the image crate (tgstation#128) * lmao we don't need jpeg dependencies for image * update `noise` to remove the rest of the junk deps * small clippy fixes (cherry picked from commit 65cf48a) * Update rust.yml * adds all-features flag to linux and windows build * reverts actions to tg's current * Update rust.yml * Update rust.yml * Update rust.yml * Update rust.yml --------- Co-authored-by: ZeWaka <zewakagamer@gmail.com> Co-authored-by: William Wallace <me@wiox.me> Co-authored-by: oranges <email@oranges.net.nz> Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com> Co-authored-by: Jared-Fogle <35135081+Jared-Fogle@users.noreply.github.com> Co-authored-by: Mark Suckerberg <29362068+MarkSuckerberg@users.noreply.github.com> Co-authored-by: Gamer025 <33846895+Gamer025@users.noreply.github.com> Co-authored-by: Jordan Brown <Cyberboss@users.noreply.github.com> Co-authored-by: EdgeLordExe <42111655+EdgeLordExe@users.noreply.github.com> Co-authored-by: adamsong <adamsong@users.noreply.github.com> Co-authored-by: pali <6pali6@gmail.com> Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Co-authored-by: vuonojenmustaturska <naksu@youzen.ext.b2.fi> Co-authored-by: MCHSL <56649176+MCHSL@users.noreply.github.com> Co-authored-by: AnturK <AnturK@users.noreply.github.com> Co-authored-by: tralezab <40974010+tralezab@users.noreply.github.com> Co-authored-by: san7890 <the@san7890.com> Co-authored-by: BraveMole <bsouchu@gmail.com> Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com>
FalloutFalcon
added a commit
to FalloutFalcon/ShiptestF
that referenced
this pull request
Jan 4, 2025
github-merge-queue Bot
pushed a commit
to shiptest-ss13/Shiptest
that referenced
this pull request
Jan 20, 2025
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may not be viewable. --> <!-- You can view Contributing.MD for a detailed description of the pull request process. --> ## About The Pull Request tgstation/tgstation#55238 tgstation/tgstation#56780 tgstation/tgstation#55515 tgstation/tgstation#57111 tgstation/tgstation#57186 tgstation/tgstation#58631 tgstation/tgstation#60249 minor backend stuff from tgstation/tgstation#55778 tgstation/tgstation#55728 <!-- Describe The Pull Request. Please be sure every change is documented or this can delay review and even discourage maintainers from merging your PR! --> ## Why It's Good For The Game prereqs for basic mobs. performance! advanced ai! <!-- Please add a short description of why you think these changes would benefit the game. If you can't justify it in words, it might not be worth adding. --> ## Changelog :cl: add: monkey smart c: add: dog smart c: add: jps, a cheap pathfinding /:cl: <!-- Both :cl:'s are required for the changelog to work! You can put your name to the right of the first :cl: if you want to overwrite your GitHub username as author ingame. --> <!-- You can use multiple of the same prefix (they're only used for the icon ingame) and delete the unneeded ones. Despite some of the tags, changelogs should generally represent how a player might be affected by the changes rather than a summary of the PR's contents. -->
github-merge-queue Bot
pushed a commit
to shiptest-ss13/Shiptest
that referenced
this pull request
Jan 20, 2025
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may not be viewable. --> <!-- You can view Contributing.MD for a detailed description of the pull request process. --> ## About The Pull Request tgstation/tgstation#55238 tgstation/tgstation#56780 tgstation/tgstation#55515 tgstation/tgstation#57111 tgstation/tgstation#57186 tgstation/tgstation#58631 tgstation/tgstation#60249 minor backend stuff from tgstation/tgstation#55778 tgstation/tgstation#55728 <!-- Describe The Pull Request. Please be sure every change is documented or this can delay review and even discourage maintainers from merging your PR! --> ## Why It's Good For The Game prereqs for basic mobs. performance! advanced ai! <!-- Please add a short description of why you think these changes would benefit the game. If you can't justify it in words, it might not be worth adding. --> ## Changelog :cl: add: monkey smart c: add: dog smart c: add: jps, a cheap pathfinding /:cl: <!-- Both :cl:'s are required for the changelog to work! You can put your name to the right of the first :cl: if you want to overwrite your GitHub username as author ingame. --> <!-- You can use multiple of the same prefix (they're only used for the icon ingame) and delete the unneeded ones. Despite some of the tags, changelogs should generally represent how a player might be affected by the changes rather than a summary of the PR's contents. -->
MrCat15352
pushed a commit
to MrCat15352/MrShiptest
that referenced
this pull request
Feb 16, 2025
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may not be viewable. --> <!-- You can view Contributing.MD for a detailed description of the pull request process. --> tgstation/tgstation#55238 tgstation/tgstation#56780 tgstation/tgstation#55515 tgstation/tgstation#57111 tgstation/tgstation#57186 tgstation/tgstation#58631 tgstation/tgstation#60249 minor backend stuff from tgstation/tgstation#55778 tgstation/tgstation#55728 <!-- Describe The Pull Request. Please be sure every change is documented or this can delay review and even discourage maintainers from merging your PR! --> prereqs for basic mobs. performance! advanced ai! <!-- Please add a short description of why you think these changes would benefit the game. If you can't justify it in words, it might not be worth adding. --> :cl: add: monkey smart c: add: dog smart c: add: jps, a cheap pathfinding /:cl: <!-- Both :cl:'s are required for the changelog to work! You can put your name to the right of the first :cl: if you want to overwrite your GitHub username as author ingame. --> <!-- You can use multiple of the same prefix (they're only used for the icon ingame) and delete the unneeded ones. Despite some of the tags, changelogs should generally represent how a player might be affected by the changes rather than a summary of the PR's contents. -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
About The Pull Request
So a month or so ago I wanted to make it so dogs in my dog AI PR could path through doors if they had access, and was told I'd need to improve our pathfinding efficiency if I wanted to use full pathfinding for them. Thus, enter JPS, a pathfinding algorithm that allows for massive timesavings in systems with uniform cost grids like ours. This code is still fairly rough and needs polishing, but it's fully functional and already shows massive savings over traditional A*! I plan for this to replace A* as our default pathing method, but I'll leave the A* code in place in case someone ever needs it for whatever reason, like if a specific case needs variable cost pathing.
Note that this allows for diagonal pathing instead of the cardinal pathing our A* uses right now, and the current version of the code costs the same to move diagonally as it does to move laterally, which may change later. There's also a lot of dummy/test code in right now in general, but you should still be able to test it out for yourself by spawning a bot like a medibot and using your PDA to summon it.
Preliminary Profile Results
A preliminary profile is available here. Using one medibot by itself on Metastation, I generated a list of 500 random blob spawn points around the station, gave the medibot all access, then let each algorithm tackle the list. The old A* algorithm took a total of 86 seconds to complete the list and processed 978065 nodes, while JPS took a total of 46 seconds and processed only 100062 nodes, for a 47% decrease in total time and an almost 90% decrease in nodes processed!
Why It's Good For The Game
Significantly cheaper pathing, which will very much come in handy for the AI datums I'm looking to dig into, what's not to like?
Changelog
🆑
refactor: Implements JPS Pathfinding!! I'll do the rest of this later
/:cl: