Skip to content
Browse files

Fix pathfinder bugs: returning nil frequently, broken A*, jump throug…

…h solid nodes (#9339)

* Fix pathfinder fail when startpos is over air
* Note down pathfinder restrictions
* Implement real A* search
* Pathfinder: Implement buildPath non-recursively
* Update find_path documentation
* Pathfinder: Check if jump path is unobstructed
* Pathfinder: Fix drop check first checking upwards
* Pathfinder: Return nil if source or dest are solid
* Pathfinder: Use priority queue for open list
  • Loading branch information
Wuzzy2 authored and sfan5 committed Mar 5, 2020
1 parent 6d8e2d2 commit 580e7e8eb902ae2faed36b4982e7e751e35f5201
Showing with 354 additions and 251 deletions.
  1. +1 −0 builtin/game/features.lua
  2. +16 −5 doc/lua_api.txt
  3. +336 −245 src/pathfinder.cpp
  4. +1 −1 src/script/lua_api/l_env.cpp
@@ -15,6 +15,7 @@ core.features = {
httpfetch_binary_data = true,
formspec_version_element = true,
area_store_persistent_ids = true,
pathfinder_works = true,

function core.has_feature(arg)
@@ -4045,6 +4045,8 @@ Utilities
formspec_version_element = true,
-- Whether AreaStore's IDs are kept on save/load (5.1.0)
area_store_persistent_ids = true,
-- Whether minetest.find_path is functional (5.2.0)
pathfinder_works = true,

* `minetest.has_feature(arg)`: returns `boolean, missing_features`
@@ -4709,16 +4711,25 @@ Environment access
* `objects`: if false, only nodes will be returned. Default is `true`.
* `liquids`: if false, liquid nodes won't be returned. Default is `false`.
* `minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)`
* returns table containing path
* returns table containing path that can be walked on
* returns a table of 3D points representing a path from `pos1` to `pos2` or
`nil` on failure.
* Reasons for failure:
* No path exists at all
* No path exists within `searchdistance` (see below)
* Start or end pos is buried in land
* `pos1`: start position
* `pos2`: end position
* `searchdistance`: number of blocks to search in each direction using a
maximum metric.
* `searchdistance`: maximum distance from the search positions to search in.
In detail: Path must be completely inside a cuboid. The minimum
`searchdistance` of 1 will confine search between `pos1` and `pos2`.
Larger values will increase the size of this cuboid in all directions
* `max_jump`: maximum height difference to consider walkable
* `max_drop`: maximum height difference to consider droppable
* `algorithm`: One of `"A*_noprefetch"` (default), `"A*"`, `"Dijkstra"`
* `algorithm`: One of `"A*_noprefetch"` (default), `"A*"`, `"Dijkstra"`.
Difference between `"A*"` and `"A*_noprefetch"` is that
`"A*"` will pre-calculate the cost-data, the other will calculate it
* `minetest.spawn_tree (pos, {treedef})`
* spawns L-system tree at given `pos` with definition in `treedef` table
* `minetest.transforming_liquid_add(pos)`

0 comments on commit 580e7e8

Please sign in to comment.
You can’t perform that action at this time.