Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 580e7e8
Show file tree
Hide file tree
Showing 4 changed files with 354 additions and 251 deletions.
1 change: 1 addition & 0 deletions builtin/game/features.lua
Expand Up @@ -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)
Expand Down
21 changes: 16 additions & 5 deletions doc/lua_api.txt
Expand Up @@ -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`
Expand Down Expand Up @@ -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`.
`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
on-the-fly
* `minetest.spawn_tree (pos, {treedef})`
* spawns L-system tree at given `pos` with definition in `treedef` table
* `minetest.transforming_liquid_add(pos)`
Expand Down

0 comments on commit 580e7e8

Please sign in to comment.