Cleanup warnings
This commit is contained in:
+38
-13
@@ -14,19 +14,19 @@ import Dodge.Data
|
||||
import Dodge.Base.Zone
|
||||
import Dodge.Base.Window
|
||||
import Dodge.Base.Collide
|
||||
import Dodge.Config.Data
|
||||
--import Dodge.Config.Data
|
||||
import Geometry
|
||||
import Picture
|
||||
|
||||
import Control.Lens
|
||||
import Control.Monad.State
|
||||
--import Control.Monad.State
|
||||
import Data.List
|
||||
import Data.Function
|
||||
--import Data.Function
|
||||
import Data.Maybe
|
||||
import Data.Bifunctor
|
||||
--import Data.Bifunctor
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import qualified Data.IntSet as IS
|
||||
import qualified Data.Set as S
|
||||
--import qualified Data.IntSet as IS
|
||||
--import qualified Data.Set as S
|
||||
|
||||
leftPad :: Int -> a -> [a] -> [a]
|
||||
leftPad i x xs = reverse $ take i $ reverse (take i xs) ++ repeat x
|
||||
@@ -44,10 +44,11 @@ midPadL i x xs ys = take j (xs ++ repeat x) ++ ys
|
||||
where
|
||||
j = i - length ys
|
||||
|
||||
{- | Implementation copied from
|
||||
- https://hackage.haskell.org/package/utility-ht-0.0.16/docs/src/Data.List.HT.Private.html#takeUntil
|
||||
-}
|
||||
takeUntil :: (a -> Bool) -> [a] -> [a]
|
||||
takeUntil f ps = case break f ps of
|
||||
(xs,[]) -> xs
|
||||
(xs, y:_ ) -> xs ++ [y]
|
||||
takeUntil p = foldr (\x xs -> x : if p x then [] else xs) []
|
||||
|
||||
you :: World -> Creature
|
||||
you w = _creatures w IM.! _yourID w
|
||||
@@ -63,6 +64,12 @@ crItem w cid = _crInv cr IM.! _crInvSel cr
|
||||
where
|
||||
cr = _creatures w IM.! cid
|
||||
|
||||
yourItemRef
|
||||
:: Applicative f
|
||||
=> World
|
||||
-> (Item -> f Item)
|
||||
-> World
|
||||
-> f World
|
||||
yourItemRef w = creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w))
|
||||
|
||||
wallNormal :: Wall -> Point2
|
||||
@@ -189,7 +196,7 @@ insertNewKey x m = case IM.lookupMax m of
|
||||
reflectPointCreature :: Point2 -> Point2 -> Creature -> Maybe (Point2, Point2, Int)
|
||||
reflectPointCreature p1 p2 cr = case collidePointCirc p1 p2 (_crRad cr) (_crPos cr) of
|
||||
Nothing -> Nothing
|
||||
Just p3 -> Just
|
||||
Just _ -> Just
|
||||
( p1
|
||||
, errorNormalizeV 35 (ssaTriPoint p2 (_crPos cr) p1 (_crRad cr) -.- _crPos cr)
|
||||
+.+ (_crPos cr -.- _crOldPos cr)
|
||||
@@ -212,7 +219,7 @@ reflectCircCreature
|
||||
-> Maybe (Point2, Point2, Int)
|
||||
reflectCircCreature rad p1 p2 cr = case collidePointCirc p1 p2 (rad + _crRad cr) (_crPos cr) of
|
||||
Nothing -> Nothing
|
||||
Just p3 -> Just
|
||||
Just _ -> Just
|
||||
( p1
|
||||
, errorNormalizeV 37 (ssaTriPoint p2 (_crPos cr) p1 (_crRad cr) -.- _crPos cr)
|
||||
+.+ (_crPos cr -.- _crOldPos cr)
|
||||
@@ -234,7 +241,9 @@ reflectCircCreatures rad p1 p2 cs
|
||||
f (a,_,_) = magV (a -.- p1)
|
||||
-- | collides a point with forcefields
|
||||
-- if found, returns point of collision, deflection if required, and the id
|
||||
collidePointFFs :: a
|
||||
collidePointFFs = undefined
|
||||
collidePointFF :: a
|
||||
collidePointFF = undefined
|
||||
--
|
||||
--collidePointFFs :: Point2 -> Point2 -> StdGen -> IM.IntMap ForceField
|
||||
@@ -380,11 +389,16 @@ circOnSomeWall p rad w
|
||||
. IM.elems
|
||||
$ wallsNearPoint p w
|
||||
{- | Test whether there is a creature of weight 4 or greater near a line. -}
|
||||
isHeavyCrNearLine :: Float -> [Point2] -> World -> Bool
|
||||
isHeavyCrNearLine
|
||||
:: Float
|
||||
-> [Point2]
|
||||
-> World
|
||||
-> Bool
|
||||
isHeavyCrNearLine d (p1:p2:_) w
|
||||
= any (\c -> circOnSeg p1 p2 (_crPos c) (d + _crRad c))
|
||||
. IM.filter (\cr -> _crMass cr > 4)
|
||||
$ _creatures w
|
||||
isHeavyCrNearLine _ _ _ = error "Testing whether creature is near empty line"
|
||||
{- | Adds the distance to the creature radius, tests whether the center is in
|
||||
the circle of this size centered at the point -}
|
||||
crsNearPoint :: Float -> Point2 -> World -> Bool
|
||||
@@ -505,7 +519,8 @@ isAnimate cr = case _crActionPlan cr of
|
||||
Inanimate -> False
|
||||
_ -> True
|
||||
|
||||
sigmoid x = x/sqrt(1+x^2)
|
||||
sigmoid :: Floating a => a -> a
|
||||
sigmoid x = x/sqrt(1+x^(2::Int))
|
||||
|
||||
{- | In order to force a list, apply with seq. -}
|
||||
forceSpine :: [a] -> ()
|
||||
@@ -514,3 +529,13 @@ forceSpine = foldr (const id) ()
|
||||
forceList :: [a] -> [a]
|
||||
forceList l = seq (forceSpine l) l
|
||||
|
||||
normalizeAnglePi :: Float -> Float
|
||||
normalizeAnglePi angle
|
||||
| normalizeAngle angle > pi = normalizeAngle angle - 2*pi
|
||||
| otherwise = normalizeAngle angle
|
||||
|
||||
-- | Taken from online, splits a list into its even and odd elements
|
||||
evenOddSplit :: [a] -> ([a],[a])
|
||||
evenOddSplit = foldr f ([],[])
|
||||
where
|
||||
f a (ls,rs) = (rs, a : ls)
|
||||
|
||||
Reference in New Issue
Block a user