Pathfinding
Feature branch: None
Pathfinding is certain to be useful when generating e.g. (who could have guessed it) paths, so it would make sense to implement a framework to facilitate it.
Suggested implementation
There is a global pathfinding graph where each node is an in-world block with six weights representing every direction.
The weights are determined by the type of block in the appropriate direction as determined by a configurable list For example:
# gold and emerald blocks have a weight of 0
# grass, sand and stone blocks have a weight of 1
# air and water have a weight of 2
PATHVALUE = (('minecraft:gold_block', 'minecraft:emerald_block'),
('minecraft:grass_block', 'minecraft:sand', 'minecraft:stone'),
('minecraft:air', 'minecraft:water'))
The global graph starts empty and must be populated by other functions, so algorithms that do not require the full map for computation are initially at an advantage. Such algorithms might include:
- BFS
- Dijkstra
- A*
Suggestion: The function signature could contain variables for both a weight list, which works as written above, OR a function, that accepts a blockname and returns a weight. This gives a bit more flexibility to the user.
You might even give function a tuple with the blocknames of the "from" block and the "to" block, which would allow things such as "continue the path as long as we are still in the same block type".
Moved to https://github.com/avdstaaij/gdpc/issues/29