Move towards simplifying impulses
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user