Start work on pathfinding

This commit is contained in:
2025-10-13 06:30:55 +01:00
parent 9e7b7a3f76
commit 6b5090e697
7 changed files with 265 additions and 287 deletions
+2 -2
View File
@@ -52,7 +52,6 @@ walkableNodeNear w p = fmap fst . find (flip (isWalkable p) w . snd) $ nodesNear
nodesNear = zonesExtract (w ^. pnZoning) $ zonesAroundPoint pnZoneSize p
makePathBetweenPs :: Point2 -> Point2 -> World -> Maybe [Point2]
--makePathBetweenPs a b w = mapMaybe (lab $ _pathGraph (_cWorld w)) <$> makePathBetween a b w
makePathBetweenPs a b w = mapMaybe (lab $ w ^. cWorld . pathGraph) <$> makePathBetween a b w
bfsNodePoints :: Int -> World -> [Point2]
@@ -61,7 +60,8 @@ bfsNodePoints n w = mapMaybe (lab g) $ bfs n g
g = w ^. cWorld . pathGraph
pointTowardsImpulse :: Point2 -> Point2 -> World -> Maybe Point2
pointTowardsImpulse a b w = (find (flip (isWalkable a) w) . reverse) =<< makePathBetweenPs a b w
pointTowardsImpulse a b w = (find (flip (isWalkable a) w) . reverse) =<<
(makePathBetweenPs a b w <&> (<>[b]))
------ continues a walk from a list of points, without repetitions
------ supposes that the list is non-empty