Inline functions in Dodge.Zone
This commit is contained in:
+9
-27
@@ -4,7 +4,6 @@ module Dodge.Path
|
||||
, makePathBetween
|
||||
, makePathBetweenPs
|
||||
, pairsToGraph
|
||||
, pairsToGraph''
|
||||
, walkableNodeNear
|
||||
, nodesNearL
|
||||
, getNodePos
|
||||
@@ -106,12 +105,11 @@ pointTowardsImpulse a b w = find (flip (isWalkable a) w) =<< makePathBetweenPs a
|
||||
-- _ -> return $ Just $ ns !! i
|
||||
--
|
||||
|
||||
pairsToGraph'' :: Set.Set (Point2,Point2) -> PathGraph
|
||||
pairsToGraph'' pairset = PathGraph gr' nodemap ncount edgemap
|
||||
pairsToGraph :: Set.Set (Point2,Point2) -> PathGraph
|
||||
pairsToGraph pairset = PathGraph gr' nodemap ncount edgemap
|
||||
where
|
||||
(gr,nodemap,ncount) = insertNodes pairset
|
||||
(gr',edgemap) = insertEdges toPathEdge pairset gr nodemap
|
||||
|
||||
|
||||
toPathEdge :: Point2 -> Point2 -> PathEdge
|
||||
toPathEdge sp' ep = PathEdge sp' ep mempty
|
||||
@@ -137,27 +135,15 @@ insertNodes pairset = runIdentity $ S.fold_ insertnode (Data.Graph.Inductive.emp
|
||||
Just _ -> (gr,nm,i)
|
||||
where
|
||||
j = i + 1
|
||||
--pairsToGraph' :: (Ord a) => (a -> a -> b) -> Set (a,a) -> (Gr a b, Map a Int, Map (V2 a) Int2)
|
||||
--pairsToGraph' f pairset = ngr'
|
||||
|
||||
--pairsToGraph :: (Ord a, Ord b) => (a -> a -> b) -> Set.Set (a,a) -> Gr a b
|
||||
--pairsToGraph f pairs = undir
|
||||
-- $ run_ Data.Graph.Inductive.empty
|
||||
-- $ insMapNodesM (Set.toList nodes') >> insMapEdgesM (Set.toList pairs')
|
||||
-- where
|
||||
-- nodeset = S.each . runIdentity $ S.fold_ getnode Set.empty id $ S.each pairset
|
||||
-- getnode nodeset' (x,y) = Set.insert x $ Set.insert y nodeset'
|
||||
-- ngr = runIdentity $ S.fold_ insertnode (Data.Graph.Inductive.empty,new) id nodeset
|
||||
-- ngr' = runIdentity $ S.fold_ insertedge ngr id $ S.each pairset
|
||||
-- insertedge (gr,nm) (x,y) = (insMapEdge nm (x,y,f x y) gr, nm)
|
||||
-- insertnode (gr,nm) n = fstsnd $ insMapNode nm n gr
|
||||
-- fstsnd (a,b,_) = (a,b)
|
||||
-- nodes' = Set.map fst pairs `Set.union` Set.map snd pairs
|
||||
-- pairs' = Set.map (\(x,y)->(x,y,f x y)) pairs
|
||||
|
||||
pairsToGraph :: (Ord a, Ord b) => (a -> a -> b) -> Set.Set (a,a) -> Gr a b
|
||||
pairsToGraph f pairs = undir
|
||||
$ run_ Data.Graph.Inductive.empty
|
||||
$ insMapNodesM (Set.toList nodes') >> insMapEdgesM (Set.toList pairs')
|
||||
where
|
||||
nodes' = Set.map fst pairs `Set.union` Set.map snd pairs
|
||||
pairs' = Set.map (\(x,y)->(x,y,f x y)) pairs
|
||||
|
||||
--findEdgesCrossing :: Point2 -> Point2 -> Gr Point2 PathEdge ->
|
||||
--
|
||||
addObstacleCrossing :: World -> EdgeObstacle -> Point2 -> Point2
|
||||
-> Gr Point2 PathEdge
|
||||
-> Gr Point2 PathEdge
|
||||
@@ -172,7 +158,3 @@ addObstacleCrossing' :: EdgeObstacle -> Point2 -> Point2
|
||||
-> World
|
||||
-> World
|
||||
addObstacleCrossing' eo a b w = w & pathGraph . pgGraph %~ addObstacleCrossing w eo a b
|
||||
|
||||
-- pg' = Set.filter (isNothing . uncurry (intersectSegSeg a b)) $ _pathGraphP w
|
||||
-- -- insertPoint pp@(_,p) = insertInZoneWith (wlZoneOfPoint p) (++) [pp]
|
||||
-- newGraph = pairsToGraph'' dist pg'
|
||||
|
||||
Reference in New Issue
Block a user