Replace some foldr with foldl'
This commit is contained in:
@@ -4,6 +4,7 @@ module Dodge.Creature.Impulse (
|
||||
impulsiveAIBefore,
|
||||
) where
|
||||
|
||||
import Data.Foldable
|
||||
import Control.Monad.State
|
||||
import Data.Bifunctor
|
||||
import Dodge.Creature.Impulse.Movement
|
||||
@@ -29,7 +30,7 @@ impulsiveAIBefore f cr w = g w & cWorld . creatures . ix (_crID cr) .~ cr'
|
||||
(g, cr') = followImpulses w $ f w cr
|
||||
|
||||
followImpulses :: World -> Creature -> (World -> World, Creature)
|
||||
followImpulses w cr = foldr f (id, cr) (_apImpulse $ _crActionPlan cr)
|
||||
followImpulses w cr = foldl' (flip f) (id, cr) (reverse $ _apImpulse $ _crActionPlan cr)
|
||||
where
|
||||
f imp (theupdate, cr') = first (. theupdate) $ followImpulse cr' w imp
|
||||
|
||||
|
||||
Reference in New Issue
Block a user