From 12ce2365c24efce74b4f509cb1cc551de76e43d2 Mon Sep 17 00:00:00 2001 From: justin Date: Tue, 23 Aug 2022 08:33:14 +0100 Subject: [PATCH] Move towards simplifying impulses --- appDodge/Main.hs | 2 +- src/Dodge/Creature/Impulse.hs | 24 +----------------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/appDodge/Main.hs b/appDodge/Main.hs index bbd53c76f..065e46e87 100644 --- a/appDodge/Main.hs +++ b/appDodge/Main.hs @@ -102,7 +102,7 @@ updateRenderSplit :: Universe -> IO Universe updateRenderSplit u = do let preData = _preloadData u updateUniverse u `par` void (doDrawing (_renderData preData) u) - return (updateUniverse u) + return $! updateUniverse u playSoundUnlessRewinding :: Universe -> IO (M.Map SoundOrigin Sound) playSoundUnlessRewinding u diff --git a/src/Dodge/Creature/Impulse.hs b/src/Dodge/Creature/Impulse.hs index 6aa55b12d..1a5622a36 100644 --- a/src/Dodge/Creature/Impulse.hs +++ b/src/Dodge/Creature/Impulse.hs @@ -2,7 +2,6 @@ module Dodge.Creature.Impulse ( impulsiveAIBefore, - followThenClearImpulses, ) where import Control.Monad.State @@ -20,17 +19,6 @@ import qualified IntMapHelp as IM import LensHelp import System.Random -impulsiveAIBeforeAfter :: - (World -> Creature -> Creature) -> - (World -> Creature -> Creature) -> - Creature -> - World -> - World -impulsiveAIBeforeAfter startup endup cr w = w' & cWorld . creatures . ix (_crID cr) .~ endup w' cr' - where - w' = g w - (g, cr') = impulsiveAI startup cr w - impulsiveAIBefore :: (World -> Creature -> Creature) -> Creature -> @@ -38,17 +26,7 @@ impulsiveAIBefore :: World impulsiveAIBefore f cr w = g w & cWorld . creatures . ix (_crID cr) .~ cr' where - (g, cr') = impulsiveAI f cr w - -impulsiveAI :: - (World -> Creature -> Creature) -> - Creature -> - World -> - (World -> World, Creature) -impulsiveAI f cr w = followImpulses w $ f w cr - -followThenClearImpulses :: Creature -> World -> World -followThenClearImpulses = impulsiveAIBeforeAfter (const id) (const $ crActionPlan . apImpulse .~ []) + (g, cr') = followImpulses w $ f w cr followImpulses :: World -> Creature -> (World -> World, Creature) followImpulses w cr = foldr f (id, cr) (_apImpulse $ _crActionPlan cr)