module Dodge.Creature.Update where
import Dodge.Data
import Dodge.Creature.State
import Dodge.Creature.Impulse
import Dodge.Creature.ChainUpdates
import LensHelp

import System.Random

-- bit of a hack to get new random generators after each creature's update
defaultImpulsive :: [World -> Creature -> Creature]
    -> Creature -> World -> World
defaultImpulsive = fmap (fmap updateRandGen) . stateUpdate . impulsiveAIBefore . chainCreatureUpdates
  where
    updateRandGen w = let (_,g) = randomR (0,1::Int) (_randGen w)
        in w & randGen .~ g
