viva_aion/pathfinding
Pathfinding - Navigation through the labyrinth
Light Cone Expansion
In Block Universe physics, the future already exists. Light cone expansion reveals all reachable positions within a given number of steps - the “possible futures” from a point.
Retrocausality
The Core (goal) exerts a “pull” on the present. We calculate which move minimizes distance to the inevitable singularity.
Types
No path exists
pub type PathError {
NoPath
InvalidStart
InvalidGoal
}
Constructors
-
NoPath -
InvalidStart -
InvalidGoal
Result of pathfinding
pub type PathResult {
PathResult(path: List(position.Position), distance: Int)
}
Constructors
-
PathResult(path: List(position.Position), distance: Int)Arguments
- path
-
The path from start to goal (inclusive)
- distance
-
Total distance
Values
pub fn distance_to_goal(
pos: position.Position,
goal: position.Position,
) -> Int
Distance to goal from position (Manhattan)
pub fn expand_light_cone(
g: grid.Grid,
origin: position.Position,
radius: Int,
) -> List(#(position.Position, Int))
Expand light cone - all reachable positions within radius
pub fn find_path(
g: grid.Grid,
start: position.Position,
goal: position.Position,
) -> Result(PathResult, PathError)
BFS to find shortest path
pub fn rank_moves(
g: grid.Grid,
current: position.Position,
goal: position.Position,
) -> List(#(position.Direction, Int))
Get all moves sorted by distance to goal (best first)
pub fn retrocausal_pull(
g: grid.Grid,
current: position.Position,
goal: position.Position,
) -> Result(position.Direction, Nil)
Retrocausal pull - which direction minimizes distance to goal?
The future (goal) exerts influence on the present decision.