roy-t / AStar

A fast 2D path finding library based on the A* algorithm. Works with both grids and graphs. Supports any .NET variant that supports .NETStandard 2.0 or higher. This library has no external dependencies. The library is licensed under the MIT license.
http://roy-t.nl
MIT License
338 stars 60 forks source link

Deterministic? #30

Closed piller187 closed 4 years ago

piller187 commented 4 years ago

Is this pathfinding library deterministic? I'm making a multiplayer game and I run this both on the client (for instant response feel) and server (to validate). My plan is to pass the starting row/col and the path that the client instance of this pathfinding found to the server and have the server use the same starting row/col and the map itself (which should be the exact same on both client/server) and run to get the path and compare it against the path the client send to make sure it 100% matches, but just curious given the map is setup and same starting row/col will I get the exact same path on the server that the client code came up with?

I don't just use the client path because I have to check for cheating (this is really the only reason for doing this check on the server) and the exact path is important as things along the path can cause harm.

bradzoob commented 4 years ago

Yep, I use the weighted search for rivers/roads in a procedural world that has to be deterministic. As long as your inputs are deterministic the outputs should be. At least I haven't noticed it deviating over the years I've been using it.

roy-t commented 4 years ago

Hey piller187, as @bradzoob said the A* algorithm (and this library) are completely deterministic. No randoms involved :)