Move toward diagnosing state update leak
This commit is contained in:
+3
-13
@@ -30,7 +30,7 @@ import qualified Data.IntMap.Lazy as IM
|
||||
import qualified Data.Map as M
|
||||
import Control.Lens
|
||||
import Data.Monoid
|
||||
import System.Random
|
||||
--import System.Random
|
||||
|
||||
update :: World -> World
|
||||
update = update' . pushSideEffects
|
||||
@@ -131,20 +131,10 @@ updateParticles w = set particles (catMaybes ps) w'
|
||||
where
|
||||
(w',ps) = mapAccumR (\a b -> _ptUpdate' b a b) w $ _particles w
|
||||
|
||||
updateCreatures' :: World -> World
|
||||
updateCreatures' w = f $ set randGen newG $ set creatures (IM.mapMaybe id crs) w
|
||||
where
|
||||
((f,newG),crs) =
|
||||
IM.mapAccum (\g' cr -> _crUpdate cr w g' cr) (id,_randGen w) $ _creatures w
|
||||
|
||||
updateToTM :: (World -> (World -> World,StdGen) -> Creature -> ((World -> World,StdGen), Maybe Creature)) -> World -> Creature -> (Endo World, Maybe Creature)
|
||||
updateToTM u w cr = case u w (id,_randGen w) cr of
|
||||
((f,_),mcr) -> (Endo f,mcr)
|
||||
|
||||
updateCreatures :: World -> World
|
||||
updateCreatures w = appEndo f $ creatures .~ IM.mapMaybe id m $ w
|
||||
updateCreatures w = appEndo f $ w & creatures .~ IM.mapMaybe id m
|
||||
where
|
||||
(f,m) = traverse (\cr -> updateToTM (_crUpdate cr) w cr) (_creatures w)
|
||||
(f,m) = traverse (\cr -> _crUpdate cr cr w) (_creatures w)
|
||||
|
||||
{- |
|
||||
Apply door mechanisms. -}
|
||||
|
||||
Reference in New Issue
Block a user