Improve chase crit searching

This commit is contained in:
2022-07-09 11:25:10 +01:00
parent f57bcebb7a
commit 9c352e4a83
8 changed files with 58 additions and 22 deletions
+7
View File
@@ -8,6 +8,7 @@ module Dodge.Path
, pairsToGraph
, getNodePos
, walkableNodeNear
, bfsNodePoints
) where
import Dodge.Data
import Dodge.Base.Collide
@@ -53,6 +54,12 @@ walkableNodeNear w p = fmap fst . find (flip (isWalkable p) w . snd) $ nodesNear
makePathBetweenPs :: Point2 -> Point2 -> World -> Maybe [Point2]
makePathBetweenPs a b w = mapMaybe (lab $ _pathGraph w) <$> makePathBetween a b w
bfsNodePoints :: Int -> World -> [Point2]
bfsNodePoints n w = mapMaybe (lab g) $ bfs n g
where
g = _pathGraph w
pointTowardsImpulse :: Point2 -> Point2 -> World -> Maybe Point2
pointTowardsImpulse a b w = (find (flip (isWalkable a) w) . reverse) =<< makePathBetweenPs a b w