Refactor launcherCrit ai
This commit is contained in:
@@ -40,18 +40,18 @@ followImpulses
|
||||
followImpulses w (f,g) cr
|
||||
= (\(f''' ,cr) -> ((f''',g'),Just cr))
|
||||
$ foldr
|
||||
(\imp (f' , cr') -> let (f'', cr'') = followImpulse imp w cr' in (f'' . f', cr''))
|
||||
(\imp (f' , cr') -> let (f'', cr'') = followImpulse cr' w imp in (f'' . f', cr''))
|
||||
(f, cr)
|
||||
(_crImpulse $ _crActionPlan cr)
|
||||
where
|
||||
g' = snd $ next g
|
||||
|
||||
followImpulse
|
||||
:: Impulse
|
||||
:: Creature
|
||||
-> World
|
||||
-> Creature
|
||||
-> Impulse
|
||||
-> (World -> World , Creature)
|
||||
followImpulse imp w cr = case imp of
|
||||
followImpulse cr w imp = case imp of
|
||||
Move p -> (id, crMvBy p cr)
|
||||
MoveForward x -> (id, crMvForward x cr)
|
||||
Turn a -> (id, creatureTurn a cr)
|
||||
@@ -69,6 +69,13 @@ followImpulse imp w cr = case imp of
|
||||
ChangeStrategy strat -> (id, cr & crActionPlan . crStrategy .~ strat)
|
||||
AddGoal gl -> (id, cr & crActionPlan . crGoal %~ (gl :) )
|
||||
ArbitraryCreatureImpulse f -> (id, f w cr)
|
||||
ImpulseUseTargetCID f -> case cr ^? crTarget . _Just of
|
||||
Just tcid -> followImpulse cr w (f tcid)
|
||||
_ -> (id,cr)
|
||||
ImpulseUseTarget f -> case cr ^? crTarget . _Just of
|
||||
Just tcid -> followImpulse cr w (f $ _creatures w IM.! tcid)
|
||||
_ -> (id,cr)
|
||||
ImpulseUseAheadPos f -> followImpulse cr w (f (_crPos cr +.+ 20 *.* unitVectorAtAngle (_crDir cr)))
|
||||
_ -> (id , cr)
|
||||
where
|
||||
cpos = _crPos cr
|
||||
@@ -153,6 +160,7 @@ performAction cr w ac = case ac of
|
||||
UseTargetCID f -> case cr ^? crTarget . _Just of
|
||||
Just tcid -> performAction cr w (f tcid)
|
||||
_ -> ([],Nothing)
|
||||
UseAheadPos f -> performAction cr w (f (_crPos cr +.+ 20 *.* unitVectorAtAngle (_crDir cr)))
|
||||
_ -> ([], Nothing)
|
||||
where
|
||||
cpos = _crPos cr
|
||||
|
||||
Reference in New Issue
Block a user