Merge branch 'efficientRuntime'

This commit is contained in:
2022-07-02 16:08:58 +01:00
10 changed files with 105 additions and 92 deletions
+15
View File
@@ -1,5 +1,6 @@
module Dodge.Block where module Dodge.Block where
import Dodge.Data import Dodge.Data
import Dodge.Base.Collide
import Dodge.Material import Dodge.Material
--import Dodge.Block.Debris --import Dodge.Block.Debris
import Dodge.Zone import Dodge.Zone
@@ -10,11 +11,14 @@ import RandomHelp
import Geometry import Geometry
--import Geometry.ConvexPoly --import Geometry.ConvexPoly
import Data.Foldable
import Data.Function import Data.Function
import Data.Maybe import Data.Maybe
import qualified Data.IntSet as IS import qualified Data.IntSet as IS
import qualified Data.IntMap.Strict as IM import qualified Data.IntMap.Strict as IM
import Control.Lens import Control.Lens
import qualified Streaming.Prelude as S
import qualified Data.Graph.Inductive as FGL
splinterBlock :: Block -> World -> World splinterBlock :: Block -> World -> World
splinterBlock bl w = foldr unshadowBlock w (_blShadows bl) -- foldr shiftTowardCen w (_blWallIDs bl) splinterBlock bl w = foldr unshadowBlock w (_blShadows bl) -- foldr shiftTowardCen w (_blWallIDs bl)
@@ -45,6 +49,7 @@ destroyBlock bl w = w
& flip (foldr unshadowBlock) (_blShadows bl) & flip (foldr unshadowBlock) (_blShadows bl)
& _blDeath bl bl & _blDeath bl bl
& deleteWallIDs wlids & deleteWallIDs wlids
& maybeClearPaths (_blPaths bl) -- must happen after the walls are deleted
& blocks %~ IM.delete (_blID bl) & blocks %~ IM.delete (_blID bl)
-- & matDesSound (_blMaterial bl) pos -- & matDesSound (_blMaterial bl) pos
& flip (foldr (wlDustAt awl)) (map (pos +.+) ps) & flip (foldr (wlDustAt awl)) (map (pos +.+) ps)
@@ -54,6 +59,16 @@ destroyBlock bl w = w
pos = fst . _wlLine $ _walls w IM.! IS.findMin wlids pos = fst . _wlLine $ _walls w IM.! IS.findMin wlids
ps = replicateM 25 (randInCirc 20) & evalState $ _randGen w ps = replicateM 25 (randInCirc 20) & evalState $ _randGen w
-- this does not handle eg doors blocking the path as well
maybeClearPaths :: [(Int,Int,PathEdge)] -> World -> World
maybeClearPaths ps w = foldl' maybeClearPath w ps
maybeClearPath :: World -> (Int,Int,PathEdge) -> World
maybeClearPath w (x,y,pe)
| runIdentity . S.any_ (const True) $ overlapSegWalls (_peStart pe) (_peEnd pe) $ wlsNearSeg (_peStart pe) (_peEnd pe) w
= w
| otherwise = w & pathGraph %~ (FGL.insEdge (x,y,pe & peObstacles .~ mempty)) . FGL.delEdge (x,y)
destroyDoor :: Door -> World -> World destroyDoor :: Door -> World -> World
destroyDoor dr w = w destroyDoor dr w = w
& _drDeath dr dr & _drDeath dr dr
+6
View File
@@ -33,6 +33,7 @@ module Dodge.Data
, module Dodge.Data.ItemAmount , module Dodge.Data.ItemAmount
, module Dodge.RoomCluster.Data , module Dodge.RoomCluster.Data
, module Dodge.Data.Room , module Dodge.Data.Room
, module Dodge.Data.PathGraph
) where ) where
import Dodge.Data.Room import Dodge.Data.Room
import Dodge.Data.PathGraph import Dodge.Data.PathGraph
@@ -148,7 +149,11 @@ data World = World
, _shapes :: IM.IntMap ForegroundShape , _shapes :: IM.IntMap ForegroundShape
, _corpses :: IM.IntMap Corpse , _corpses :: IM.IntMap Corpse
, _clickMousePos :: Point2 , _clickMousePos :: Point2
<<<<<<< HEAD
, _pathGraph :: PathGraph , _pathGraph :: PathGraph
=======
, _pathGraph :: Gr Point2 PathEdge
>>>>>>> efficientRuntime
, _pathGraphP :: S.Set (Point2,Point2) , _pathGraphP :: S.Set (Point2,Point2)
, _pnZoning :: Zoning [] (Int,Point2) , _pnZoning :: Zoning [] (Int,Point2)
, _peZoning :: Zoning [] (Int,Int,PathEdge) , _peZoning :: Zoning [] (Int,Int,PathEdge)
@@ -952,6 +957,7 @@ data Block = Block
, _blDir :: Float , _blDir :: Float
, _blDraw :: Block -> SPic , _blDraw :: Block -> SPic
, _blDeath :: Block -> World -> World , _blDeath :: Block -> World -> World
, _blPaths :: [(Int,Int,PathEdge)]
} }
data TerminalStatus = TerminalOff | TerminalBusy | TerminalReady data TerminalStatus = TerminalOff | TerminalBusy | TerminalReady
deriving (Eq,Ord,Show) deriving (Eq,Ord,Show)
+2
View File
@@ -15,6 +15,7 @@ data PathGraph = PathGraph
data PathEdge = PathEdge data PathEdge = PathEdge
{_peStart :: Point2 {_peStart :: Point2
,_peEnd :: Point2 ,_peEnd :: Point2
,_peDist :: Float
,_peObstacles :: Set.Set EdgeObstacle ,_peObstacles :: Set.Set EdgeObstacle
} }
deriving (Eq,Ord,Show) deriving (Eq,Ord,Show)
@@ -26,3 +27,4 @@ data EdgeObstacle
deriving (Eq,Ord,Show,Bounded,Enum) deriving (Eq,Ord,Show,Bounded,Enum)
makeLenses ''PathGraph makeLenses ''PathGraph
makeLenses ''PathEdge
+1
View File
@@ -15,6 +15,7 @@ defaultBlock = Block
, _blDraw = const mempty , _blDraw = const mempty
, _blDeath = makeBlockDebris , _blDeath = makeBlockDebris
, _blObstructs = [] , _blObstructs = []
, _blPaths = []
} }
defaultDirtBlock :: Block defaultDirtBlock :: Block
defaultDirtBlock = defaultBlock & blHP .~ 50 defaultDirtBlock = defaultBlock & blHP .~ 50
+2 -2
View File
@@ -76,8 +76,8 @@ defaultWorld = World
, _clickMousePos = V2 0 0 , _clickMousePos = V2 0 0
, _pathGraph = PathGraph Data.Graph.Inductive.Graph.empty mempty 0 mempty , _pathGraph = PathGraph Data.Graph.Inductive.Graph.empty mempty 0 mempty
, _pathGraphP = mempty , _pathGraphP = mempty
, _pnZoning = Zoning mempty pnZoneSize (zonePos snd) , _pnZoning = Zoning mempty wlZoneSize (zonePos snd)
, _peZoning = Zoning mempty pnZoneSize (\x (_,_,PathEdge p q _) -> zoneOfSeg x p q) , _peZoning = Zoning mempty wlZoneSize (\x (_,_,e) -> zoneOfSeg x (_peStart e) (_peEnd e))
, _hud = HUD , _hud = HUD
{ _hudElement = DisplayInventory NoSubInventory { _hudElement = DisplayInventory NoSubInventory
, _carteCenter = V2 0 0 , _carteCenter = V2 0 0
+3 -3
View File
@@ -47,11 +47,11 @@ generateLevelFromRoomList gr' w = initWallZoning
, _pathGraphP = pairPath , _pathGraphP = pairPath
} }
& pnZoning %~ (\zn -> foldl' (flip $ updateZoning (:)) (zn & znObjects .~ mempty) & pnZoning %~ (\zn -> foldl' (flip $ updateZoning (:)) (zn & znObjects .~ mempty)
(labNodes (_pgGraph path))) (labNodes path))
& peZoning %~ (\zn -> foldl' (flip $ updateZoning (:)) (zn & znObjects .~ mempty) & peZoning %~ (\zn -> foldl' (flip $ updateZoning (:)) (zn & znObjects .~ mempty)
(labEdges (_pgGraph path))) (labEdges path))
where where
path = pairsToGraph pairPath (_,path) = pairsToGraph pairPath
pairPath = foldMap _rmPath rs pairPath = foldMap _rmPath rs
rs = map doRoomShift $ IM.elems rs' rs = map doRoomShift $ IM.elems rs'
rs'= mapM shuffleRoomPos gr' & evalState $ _randGen w rs'= mapM shuffleRoomPos gr' & evalState $ _randGen w
+45 -73
View File
@@ -3,11 +3,10 @@ module Dodge.Path
( pointTowardsImpulse ( pointTowardsImpulse
, makePathBetween , makePathBetween
, makePathBetweenPs , makePathBetweenPs
, obstructPathsCrossing
, pairsToGraph , pairsToGraph
, walkableNodeNear
, nodesNearL
, getNodePos , getNodePos
, addObstacleCrossing' , walkableNodeNear
) where ) where
import Dodge.Data import Dodge.Data
import Dodge.Base.Collide import Dodge.Base.Collide
@@ -22,38 +21,33 @@ import Data.List
import Data.Graph.Inductive hiding ((&)) import Data.Graph.Inductive hiding ((&))
import Data.Set (Set) import Data.Set (Set)
import qualified Data.Set as Set import qualified Data.Set as Set
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
import Data.Map.Strict (Map)
import StreamingHelp
import qualified Streaming.Prelude as S import qualified Streaming.Prelude as S
import StreamingHelp import StreamingHelp
--import Data.Graph.Inductive.PatriciaTree --import Data.Graph.Inductive.PatriciaTree
--import Data.Graph.Inductive.Graph hiding ((&)) --import Data.Graph.Inductive.Graph hiding ((&))
getNodePos :: Int -> World -> Maybe Point2 getNodePos :: Int -> World -> Maybe Point2
getNodePos i w = _pgGraph (_pathGraph w) `lab` i getNodePos i w = _pathGraph w `lab` i
makePathBetween :: Point2 -> Point2 -> World -> Maybe [Int] makePathBetween :: Point2 -> Point2 -> World -> Maybe [Int]
makePathBetween a b w = do -- join $ sp <$> a' <*> b' <*> return (_pathGraph w) makePathBetween a b w = do -- join $ sp <$> a' <*> b' <*> return (_pathGraph w)
(na,_) <- walkableNodeNear a w na <- walkableNodeNear w a
(nb,_) <- walkableNodeNear b w nb <- walkableNodeNear w b
sp na nb (second pathDist $ efilter noobstacle $ _pgGraph $ _pathGraph w) sp na nb (second _peDist (_pathGraph w))
where where
noobstacle (_,_,PathEdge _ _ s) = null s --nodesNear p = concat $ lookLookups (zoneNearPointIP p) (_pathPoints w)
-- nodesNear p = runIdentity . S.toList_ $ nearPoint _pnZoning p w
-- walkableNodeNear p = fmap fst . find (flip (isWalkable p) w . snd) $ nodesNear p
pathDist :: PathEdge -> Float walkableNodeNear :: World -> Point2 -> Maybe Int
pathDist pe = dist (_peStart pe) (_peEnd pe)
walkableNodeNear :: Point2 -> World -> Maybe (Int,Point2)
{-# INLINE walkableNodeNear #-} {-# INLINE walkableNodeNear #-}
walkableNodeNear p w = minStreamOn (dist p . snd) walkableNodeNear w p = fmap fst . find (flip (isWalkable p) w . snd) $ nodesNear
. S.filter (flip (isWalkable p) w . snd) $ nodesNear p w where
--nodesNear = runIdentity . S.toList_ $ nearPoint _pnZoning p w
nodesNear :: Point2 -> World -> StreamOf (Int,Point2) nodesNear = runIdentity . S.toList_ $ aroundPoint _pnZoning p w
{-# INLINE nodesNear #-}
nodesNear = aroundPoint _pnZoning
nodesNearL :: Point2 -> World -> [(Int,Point2)]
nodesNearL p = runIdentity . S.toList_ . nodesNear p
makePathBetweenPs :: Point2 -> Point2 -> World -> Maybe [Point2] makePathBetweenPs :: Point2 -> Point2 -> World -> Maybe [Point2]
makePathBetweenPs a b w = mapMaybe (lab $ _pgGraph $ _pathGraph w) <$> makePathBetween a b w makePathBetweenPs a b w = mapMaybe (lab $ _pgGraph $ _pathGraph w) <$> makePathBetween a b w
@@ -104,62 +98,40 @@ pointTowardsImpulse a b w = find (flip (isWalkable a) w) =<< makePathBetweenPs a
-- [] -> return Nothing -- [] -> return Nothing
-- _ -> return $ Just $ ns !! i -- _ -> return $ Just $ ns !! i
-- --
pairsToGraph :: Set.Set (Point2,Point2) -> (Map (V2 Point2) (Int,Int,PathEdge),Gr Point2 PathEdge)
pairsToGraph :: Set.Set (Point2,Point2) -> PathGraph pairsToGraph pairs = addEdges nodemap gr $ S.each pairs
pairsToGraph pairset = PathGraph gr' nodemap ncount edgemap
where where
(gr,nodemap,ncount) = insertNodes pairset (nodemap,_,gr) = addNodes $ S.map fst (S.each pairs) <> S.map snd (S.each pairs)
(gr',edgemap) = insertEdges toPathEdge gr nodemap pairset -- let nodes' = Set.map fst pairs `Set.union` Set.map snd pairs
-- pairs' = Set.map (\(x,y)->(x,y,f x y)) pairs
-- in undir $ run_ Data.Graph.Inductive.empty $ insMapNodesM (Set.toList nodes') >> insMapEdgesM (Set.toList pairs')
toPathEdge :: Point2 -> Point2 -> PathEdge addNodes :: StreamOf Point2 -> (Map Point2 Int,Int,Gr Point2 PathEdge)
toPathEdge sp' ep = PathEdge sp' ep mempty addNodes = runIdentity . S.fold_ f (mempty,0,Data.Graph.Inductive.empty) id
insertEdges :: (Point2 -> Point2 -> b)
-> Gr Point2 b -> Map Point2 Int
-> Set (Point2,Point2)
-> (Gr Point2 b, Map (V2 Point2) (Int,Int,b))
insertEdges efunc gr nm = runIdentity . S.fold_ (insertEdge efunc nm) (gr,mempty) id . S.each
insertEdge :: Ord a => (a -> a -> c) -> Map a Int -> (Gr b c,Map (V2 a) (Int,Int,c))
-> (a,a)
-> (Gr b c,Map (V2 a) (Int,Int,c))
insertEdge efunc nm (gr',em) (a,b) = (insEdge (f a,f b,efunc a b) gr'
, M.insert (V2 a b) (f a,f b,efunc a b) em)
where where
f x = nm M.! x f (nodemap,i,gr) p = case nodemap M.!? p of
Just _ -> (nodemap,i,gr)
insertNodes :: Set (Point2,Point2) -> (Gr Point2 b, Map Point2 Int, Int) Nothing -> (nodemap & at p ?~i ,i+1, insNode (i,p) gr)
insertNodes pairset = runIdentity $ S.fold_ insertnode (Data.Graph.Inductive.empty,mempty,0) id nodestream addEdges :: Map Point2 Int -> Gr Point2 PathEdge -> StreamOf (Point2,Point2)
-> (Map (V2 Point2) (Int,Int,PathEdge) , Gr Point2 PathEdge)
addEdges nodemap gr = runIdentity . S.fold_ f (mempty,gr) id
where where
nodestream :: StreamOf Point2 f (edgemap,gr') (a,b) = (M.insert (V2 a b) theedge edgemap
nodestream = S.each . runIdentity $ S.fold_ getnode Set.empty id $ S.each pairset , insEdge theedge gr'
getnode strm (x,y) = Set.insert x $ Set.insert y strm )
insertnode :: (Gr Point2 b,Map Point2 Int,Int) -> Point2 -> (Gr Point2 b,Map Point2 Int,Int)
insertnode (gr,nm,i) n = case M.lookup n nm of
Nothing -> (insNode (j,n) gr, M.insert n j nm, j)
Just _ -> (gr,nm,i)
where where
j = i + 1 theedge = (g a,g b,PathEdge a b (dist a b) mempty)
g a = nodemap M.! a
--pairsToGraph :: (Ord a, Ord b) => (a -> a -> b) -> Set.Set (a,a) -> Gr a b obstructPathsCrossing :: Point2 -> Point2 -> World -> ( World, [(Int,Int,PathEdge)])
--pairsToGraph f pairs = undir obstructPathsCrossing sp ep w =
-- $ run_ Data.Graph.Inductive.empty ( w & pathGraph %~ updateedges
-- $ insMapNodesM (Set.toList nodes') >> insMapEdgesM (Set.toList pairs') , runIdentity $ S.toList_ edges
-- where )
-- nodes' = Set.map fst pairs `Set.union` Set.map snd pairs
-- pairs' = Set.map (\(x,y)->(x,y,f x y)) pairs
addObstacleCrossing :: World -> EdgeObstacle -> Point2 -> Point2
-> Gr Point2 PathEdge
-> Gr Point2 PathEdge
addObstacleCrossing w eo a b gr = runIdentity $ S.fold_ updateedge gr id paths
where where
updateedge gr' (xi,yi,PathEdge x y obs) = insEdge (xi,yi,PathEdge x y (Set.insert eo obs)) edges = S.filter edgecrosses $ nearSeg _peZoning sp ep w
$ delEdge (xi,yi) gr' edgecrosses (_,_,pe) = isJust $ intersectSegSeg sp ep (_peStart pe) (_peEnd pe)
paths = S.filter f $ nearSeg _peZoning a b w updateedges gr = runIdentity $ S.fold_ updateedge gr id edges
f (_,_,PathEdge x y _) = isJust $ intersectSegSeg x y a b updateedge gr (x,y,pe)
= insEdge (x,y,pe & peObstacles . at BlockObstacle .~ Just ()) $ delEdge (x,y) gr
addObstacleCrossing' :: EdgeObstacle -> Point2 -> Point2
-> World
-> World
addObstacleCrossing' eo a b w = w & pathGraph . pgGraph %~ addObstacleCrossing w eo a b
+4 -4
View File
@@ -120,10 +120,10 @@ evaluateRandPS rgen ps w = placeSpotID ps evaluatedType (set randGen g w)
(evaluatedType, g) = runState rgen (_randGen w) (evaluatedType, g) = runState rgen (_randGen w)
placeWallPoly :: [Point2] -> Wall -> World -> World placeWallPoly :: [Point2] -> Wall -> World -> World
--placeWallPoly ps wl = over walls (placeWalls ps wl) placeWallPoly ps wl = -- rmCrossPaths .
placeWallPoly ps wl = rmCrossPaths . over walls (placeWalls ps wl) over walls (placeWalls ps wl)
where -- where
rmCrossPaths w = foldr (uncurry (addObstacleCrossing' WallObstacle)) w $ loopPairs ps -- rmCrossPaths w = foldr (uncurry obstructPathsCrossing) w $ loopPairs ps
placeWalls :: [Point2] -> Wall -> IM.IntMap Wall -> IM.IntMap Wall placeWalls :: [Point2] -> Wall -> IM.IntMap Wall -> IM.IntMap Wall
placeWalls qs wl wls = foldl' (addPane wl) wls pairs placeWalls qs wl wls = foldl' (addPane wl) wls pairs
+17 -6
View File
@@ -24,13 +24,13 @@ plBlock
-> (Int,World) -> (Int,World)
plBlock [] _ _ _ = error "Trying to add a block with incomplete polygon" plBlock [] _ _ _ = error "Trying to add a block with incomplete polygon"
plBlock (p:ps) bl wl w = (,) blid $ w plBlock (p:ps) bl wl w = (,) blid $ w
& flip (foldr insertWall) wls
& blocks . at blid ?~ bl & blocks . at blid ?~ bl
{ _blID = blid { _blID = blid
, _blWallIDs = IS.fromList is , _blWallIDs = IS.fromList is
, _blShadows = [] , _blShadows = []
, _blFootprint = p:ps , _blFootprint = p:ps
} }
& insertWalls blid wls
where where
blid = IM.newKey $ _blocks w blid = IM.newKey $ _blocks w
lns = zip (p:ps) (ps ++ [p]) lns = zip (p:ps) (ps ++ [p])
@@ -50,7 +50,8 @@ plLineBlock
-> World -> World
-> (Int, World) -> (Int, World)
plLineBlock basePane blwidth a b gw = ( 0 plLineBlock basePane blwidth a b gw = ( 0
, foldr insertWall (insertBlocks gw) listWalls -- , foldr insertWall (insertBlocks gw) listWalls
, insertBlocks gw
) )
where where
depth = blwidth depth = blwidth
@@ -64,13 +65,17 @@ plLineBlock basePane blwidth a b gw = ( 0
linesAt p = loopPairs $ cornersAt p linesAt p = loopPairs $ cornersAt p
wlid = IM.newKey $ _walls gw wlid = IM.newKey $ _walls gw
blid = IM.newKey $ _blocks gw blid = IM.newKey $ _blocks gw
insertBlock (i,p) = over blocks $ IM.insert (i+blid) Block insertBlock (i,p) =
insertWalls (i + blid) (makeWallAt p i)
. (over blocks $ IM.insert (i+blid) Block
{ _blID = i + blid, _blWallIDs = IS.fromList $ ksAtI i { _blID = i + blid, _blWallIDs = IS.fromList $ ksAtI i
, _blHP = 1000, _blShadows = shadowsAt i , _blHP = 1000, _blShadows = shadowsAt i
, _blDir = 0 -- THIS IS NOT SENSIBLE. TODO rethink block positioning , _blDir = 0 -- THIS IS NOT SENSIBLE. TODO rethink block positioning
, _blFootprint = cornersAt p -- TODO check winding (clockwise, anticlockwise) , _blFootprint = cornersAt p -- TODO check winding (clockwise, anticlockwise)
, _blObstructs = [] , _blObstructs = []
, _blPaths = []
, _blPos = p, _blDraw = const mempty , _blDeath = makeBlockDebris} , _blPos = p, _blDraw = const mempty , _blDeath = makeBlockDebris}
)
insertBlocks = flip (foldr insertBlock) $ zip is blockCenPs insertBlocks = flip (foldr insertBlock) $ zip is blockCenPs
ksAtI i = map ( + (wlid + i*4) ) [0,1,2,3] ksAtI i = map ( + (wlid + i*4) ) [0,1,2,3]
visibilityAt i visibilityAt i
@@ -90,6 +95,12 @@ plLineBlock basePane blwidth a b gw = ( 0
} }
listWalls = concat $ zipWith makeWallAt blockCenPs is listWalls = concat $ zipWith makeWallAt blockCenPs is
insertWall :: Wall -> World -> World -- | Must be done after inserting the block
insertWall wl = (walls . at (_wlID wl) ?~ wl) insertWalls :: Int -> [Wall] -> World -> World
. uncurry (addObstacleCrossing' BlockObstacle) (_wlLine wl) insertWalls blid wls w = w' & blocks . ix blid . blPaths .~ concat paths
where
(w',paths) = mapAccumR (flip insertWall) w wls
insertWall :: Wall -> World -> (World,[(Int,Int,PathEdge)])
insertWall wl = uncurry obstructPathsCrossing (_wlLine wl)
. (walls . at (_wlID wl) ?~ wl)
+9 -3
View File
@@ -82,7 +82,7 @@ extraPics cfig w = pictures (_decorations w)
<> concatMapPic clDraw (_clouds w ) <> concatMapPic clDraw (_clouds w )
<> concatMapPic ppDraw (_pressPlates w ) <> concatMapPic ppDraw (_pressPlates w )
<> viewClipBounds cfig w <> viewClipBounds cfig w
<> debugDraw cfig w -- <> debugDraw cfig w
debugDraw :: Configuration -> World -> Picture debugDraw :: Configuration -> World -> Picture
debugDraw cfig w = pic debugDraw cfig w = pic
@@ -122,8 +122,8 @@ drawCreatureDisplayTexts w = foldMap (creatureDisplayText w) (_creatures w)
drawPathBetween :: World -> Picture drawPathBetween :: World -> Picture
drawPathBetween w = setLayer DebugLayer drawPathBetween w = setLayer DebugLayer
$ color yellow (foldMap (arrowPath . mapMaybe nodepos) nodelist) $ color yellow (foldMap (arrowPath . mapMaybe nodepos) nodelist)
<> foldMap (color green . arrow sp) (nodepos =<< nodelist ^? _Just . ix 0) <> foldMap (color green . arrow sp) (nodepos =<< walkableNodeNear w sp)
<> foldMap (color cyan . flip arrow ep) (nodepos =<< lastOf traverse =<< nodelist ^? _Just) <> foldMap (color cyan . flip arrow ep) (nodepos =<< walkableNodeNear w ep)
where where
nodepos = (`getNodePos` w) nodepos = (`getNodePos` w)
nodelist = makePathBetween sp ep w nodelist = makePathBetween sp ep w
@@ -133,9 +133,15 @@ drawPathBetween w = setLayer DebugLayer
drawNodesNearSelect :: World -> Picture drawNodesNearSelect :: World -> Picture
drawNodesNearSelect w = setLayer DebugLayer $ drawNodesNearSelect w = setLayer DebugLayer $
runIdentity (S.foldMap_ (drawZone pnZoneSize) (zoneAroundPoint pnZoneSize sp)) runIdentity (S.foldMap_ (drawZone pnZoneSize) (zoneAroundPoint pnZoneSize sp))
<<<<<<< HEAD
<> color red (foldMap (drawCross . snd) $ nodesNearL sp w) <> color red (foldMap (drawCross . snd) $ nodesNearL sp w)
<> color green (drawCross sp) <> color green (drawCross sp)
<> color cyan (foldMap (drawCross . snd) $ walkableNodeNear sp w) <> color cyan (foldMap (drawCross . snd) $ walkableNodeNear sp w)
=======
-- <> color red (foldMap (drawCross . snd) $ nodesNearL sp w)
<> color green (drawCross sp)
-- <> color cyan (foldMap (drawCross . snd) $ walkableNodeNear sp w)
>>>>>>> efficientRuntime
where where
sp = _lSelect w sp = _lSelect w