grid_pathfinding icon indicating copy to clipboard operation
grid_pathfinding copied to clipboard

Differing paths for different directions

Open bjrnt opened this issue 3 years ago • 1 comments

Hello!

I'm very new to Rust and game development and this crate seemed like a good way to get started. I am however running into issues as the paths generated by the library are different when going in different directions.

As an example:

Computing path from Point { x: 14, y: 10 } to Point { x: 14, y: 25 }
Found Some(461v0) at Point { x: 14, y: 11 }
Found Some(462v0) at Point { x: 14, y: 12 }
Found Some(463v0) at Point { x: 14, y: 13 }
Found Some(464v0) at Point { x: 14, y: 14 }
Found Some(465v0) at Point { x: 14, y: 15 }
Found Some(498v0) at Point { x: 15, y: 16 }
Found Some(499v0) at Point { x: 15, y: 17 }
Found Some(500v0) at Point { x: 15, y: 18 }
Found Some(501v0) at Point { x: 15, y: 19 }
Found Some(502v0) at Point { x: 15, y: 20 }
Found Some(503v0) at Point { x: 15, y: 21 }
Found Some(504v0) at Point { x: 15, y: 22 }
Found Some(505v0) at Point { x: 15, y: 23 }
Found Some(506v0) at Point { x: 15, y: 24 }
Computing path from Point { x: 14, y: 25 } to Point { x: 14, y: 10 }
Found Some(506v0) at Point { x: 15, y: 24 }
Found Some(505v0) at Point { x: 15, y: 23 }
Found Some(504v0) at Point { x: 15, y: 22 }
Found Some(503v0) at Point { x: 15, y: 21 }
Found Some(502v0) at Point { x: 15, y: 20 }
Found Some(501v0) at Point { x: 15, y: 19 }
Found Some(500v0) at Point { x: 15, y: 18 }
Found Some(467v0) at Point { x: 14, y: 17 }
Found Some(434v0) at Point { x: 13, y: 16 }
Found Some(433v0) at Point { x: 13, y: 15 }
Found Some(432v0) at Point { x: 13, y: 14 }
Found Some(431v0) at Point { x: 13, y: 13 }
Found Some(398v0) at Point { x: 12, y: 12 }
Found Some(397v0) at Point { x: 12, y: 11 }
Found Some(396v0) at Point { x: 12, y: 10 }
Found Some(427v0) at Point { x: 13, y: 9 }

Here are two images displaying the different paths. As you can see, one of them is pretty strange. Just thought I'd let you know.

Thanks!

Screen Shot 2022-11-16 at 5 34 38 PM Screen Shot 2022-11-16 at 5 34 45 PM

bjrnt avatar Nov 17 '22 01:11 bjrnt

Thank you for bringing this to attention, would you mind sharing code using which this can be reproduced (via email perhaps)? Then I can get to the bottom of why it's generating suboptimal paths

tbvanderwoude avatar May 17 '23 12:05 tbvanderwoude

This turned out to be related to the problem fixed in commit 16c47b0. Improved pruning was generating nodes without adding the base cost of the pruned node. The fix will be included in version v0.2.0 as well as v0.1.3

tbvanderwoude avatar Jul 30 '24 12:07 tbvanderwoude