Hack solution, update random generator for each creature

This commit is contained in:
2022-05-19 13:58:00 +01:00
parent f8af186691
commit 7f3449dd5c
2 changed files with 10 additions and 2 deletions
+2 -1
View File
@@ -48,7 +48,8 @@ chaseCrit = defaultCreature
, _crFaction = ColorFaction green
, _crVocalization = Vocalization seagullChatterS
[seagullBarkS
,seagullChatterS,seagullWhistleS
,seagullChatterS
,seagullWhistleS
,seagullWhistle1S
,seagullCryS
] 50 0
+8 -1
View File
@@ -3,7 +3,14 @@ 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 = stateUpdate . impulsiveAIBefore . chainCreatureUpdates
defaultImpulsive = fmap (fmap updateRandGen) . stateUpdate . impulsiveAIBefore . chainCreatureUpdates
where
updateRandGen w = let (_,g) = randomR (0,1::Int) (_randGen w)
in w & randGen .~ g