astar 0.0 → 0.1
raw patch · 2 files changed
+9/−4 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Data/Graph/AStar.hs +8/−3
- astar.cabal +1/−1
Data/Graph/AStar.hs view
@@ -64,10 +64,11 @@ -> (a -> a -> c) -- ^ Distance function between neighbouring vertices of the graph. This will -- never be applied to vertices that are not neighbours, so may be undefined -- on pairs that are not neighbours in the graph.- -> (a -> c) -- ^ Heuristic distance to the (nearest) goal.+ -> (a -> c) -- ^ Heuristic distance to the (nearest) goal. This should never overestimate the+ -- distance, or else the path found may not be minimal. -> (a -> Bool) -- ^ The goal, specified as a boolean predicate on vertices. -> a -- ^ The vertex to start searching from.- -> Maybe [a] -- ^ An optimal path, if any path exists.+ -> Maybe [a] -- ^ An optimal path, if any path exists. This excludes the starting vertex. aStar graph dist heur goal start = let s = runAStar graph dist heur goal start in case end s of@@ -75,9 +76,13 @@ Just e -> Just (reverse . takeWhile (not . (== start)) . iterate (cameFrom s !) $ e) plane :: (Integer, Integer) -> Set (Integer, Integer)-plane (x,y) = Set.fromList [(x-1,y),(x+1,y),(x,y-1),(x,y+1),(x-1,y-1),(x+1,y+1),(x-1,y+1),(x+1,y-1)]+plane (x,y) = Set.fromList [(x-1,y),(x+1,y),(x,y-1),(x,y+1)] +planeHole :: (Integer, Integer) -> Set (Integer, Integer)+planeHole (x,y) = Set.filter (\(u,v) -> planeDist (u,v) (0,0) > 10) (plane (x,y))+ planeDist :: (Integer, Integer) -> (Integer, Integer) -> Double planeDist (x1,y1) (x2,y2) = sqrt ((x1'-x2')^2 + (y1'-y2')^2) where [x1',y1',x2',y2'] = map fromInteger [x1,y1,x2,y2]+
astar.cabal view
@@ -1,5 +1,5 @@ name: astar-version: 0.0+version: 0.1 synopsis: General A* search algorithm. description: This is a data-structure independent implementation of A* search. category: Data