26 lines
904 B
Haskell
26 lines
904 B
Haskell
module Dodge.Creature.Action.Flee
|
|
where
|
|
import Dodge.Data
|
|
import Geometry
|
|
|
|
import Data.List
|
|
import Data.Maybe
|
|
|
|
retreatPointForFrom
|
|
:: Float -> World -> Creature -> Point2 -> Maybe Point2
|
|
retreatPointForFrom d w cr p
|
|
= listToMaybe
|
|
. sortOn (dist cpos)
|
|
$ divideCircle 10 p d
|
|
where
|
|
cpos = _crPos cr
|
|
-- = head $ sortBy (compare `on` (\p -> dist p ypos < 300)) $ retreatP'' : retreatPs
|
|
-- where
|
|
-- retreatPs = sortBy (compare `on` dist cpos) $ map f $ nRaysRad 8 400
|
|
-- where f p = fromMaybe (ypos +.+ p) $ fmap fst
|
|
-- $ reflectPointWalls ypos (ypos +.+ p) (wallsAlongLine ypos (ypos +.+ p) w)
|
|
-- retreatP' = cpos +.+ 300 *.* (cpos -.- ypos)
|
|
-- retreatP'' = fromMaybe retreatP' $ fmap fst
|
|
-- $ reflectPointWalls ypos retreatP'
|
|
-- $ wallsAlongLine ypos retreatP' w
|