Refactor ai
This commit is contained in:
+141
-1
@@ -6,6 +6,7 @@ circular imports are probably not a good idea.
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
module Dodge.Data
|
||||
( module Dodge.Data
|
||||
, module Dodge.Data.DamageType
|
||||
@@ -33,9 +34,11 @@ import Geometry.Data
|
||||
import Sound.Data
|
||||
import qualified DoubleStack as DS
|
||||
|
||||
import GHC.Generics
|
||||
import Control.Lens
|
||||
import Control.Monad.State
|
||||
import System.Random
|
||||
import Data.Data
|
||||
import Data.Graph.Inductive
|
||||
import Data.Int (Int16)
|
||||
import qualified Data.Set as S
|
||||
@@ -151,11 +154,13 @@ data Creature = Creature
|
||||
, _crCorpse :: Picture
|
||||
, _crApplyDamage :: [DamageType] -> Creature -> (World -> World,Creature)
|
||||
, _crStance :: Stance
|
||||
, _crRationality :: Rationality
|
||||
, _crActionPlan :: ActionPlan
|
||||
, _crMeleeCooldown :: Maybe Int
|
||||
, _crAwakeLevel :: AwakeLevel
|
||||
, _crAttentionDir :: AttentionDir
|
||||
, _crAwarenessLevel :: IM.IntMap AwarenessLevel
|
||||
, _crFaction :: Faction
|
||||
, _crTarget :: Maybe Int
|
||||
}
|
||||
data WorldState
|
||||
= DoorNumOpen Int
|
||||
@@ -443,6 +448,138 @@ data ForceField = FF
|
||||
}
|
||||
data FFState = FFDestroyable { _ffsHP :: Int }
|
||||
|
||||
data ActionPlan
|
||||
= Inanimate
|
||||
| ActionPlan
|
||||
{_crImpulse :: [Impulse]
|
||||
,_crAction :: [Action]
|
||||
,_crStrategy :: Strategy
|
||||
,_crGoal :: [Goal]
|
||||
}
|
||||
data Impulse
|
||||
= Move Point2
|
||||
| MoveForward Float
|
||||
| StepForward
|
||||
| Turn Float
|
||||
| RandomTurn Float
|
||||
| TurnToward Point2 Float
|
||||
| TurnTo Point2
|
||||
| UseItem
|
||||
| SwitchToItem Int
|
||||
| DropItem
|
||||
| PickupNearby Int
|
||||
| UseWorldObject Int
|
||||
| Bark -- placeholder for various communication types
|
||||
| UseIntrinsicAbility
|
||||
| Melee Int
|
||||
| ChangePosture Posture
|
||||
| MakeSound Int
|
||||
| ChangeStrategy Strategy
|
||||
| AddGoal Goal
|
||||
| ArbitraryCreatureImpulse (World -> Creature -> Creature)
|
||||
-- deriving (Eq,Ord,Show)
|
||||
data Action
|
||||
= Attack
|
||||
{_attackTargetID :: Int}
|
||||
| AimAtCloseSlow
|
||||
{_targetID :: Int
|
||||
,_targetSeenAt :: Point2
|
||||
,_aimSpeed :: Float
|
||||
,_slowAimSpeed :: Float
|
||||
,_slowAimAngle :: Float
|
||||
}
|
||||
| MeleeAttack
|
||||
{_meleeAttackLastSeen :: Point2
|
||||
,_meleeAttackTargetID :: Int
|
||||
}
|
||||
| PathTo
|
||||
{_pathToPoint :: Point2
|
||||
}
|
||||
| FleeFrom
|
||||
{_fleeFromCID :: Int
|
||||
}
|
||||
| HealSelf
|
||||
| DefendSelf
|
||||
| Protect
|
||||
{_protectCID :: Int
|
||||
}
|
||||
| SearchFor
|
||||
{_searchForCID :: Int
|
||||
}
|
||||
| Search
|
||||
| PickupItem
|
||||
{_pickupItemID :: Int
|
||||
}
|
||||
| ShootTillEmpty
|
||||
| ImpulsesList
|
||||
{_impulsesListList :: [[Impulse]]
|
||||
}
|
||||
| DoImpulses
|
||||
{_doImpulsesList :: [Impulse]
|
||||
}
|
||||
| DrawWeapon
|
||||
| HolsterWeapon
|
||||
| WaitThen
|
||||
{_waitThenTimer :: Int
|
||||
,_waitThenAction :: Action
|
||||
}
|
||||
| DoActionWhile
|
||||
{_doActionWhileAction :: Action
|
||||
,_doActionWhileCondition :: ( (World, Creature) -> Bool)
|
||||
}
|
||||
| DoActionIfElse
|
||||
{_doActionIfElseIfAction :: Action
|
||||
,_doActionIfElseCondition :: ( (World, Creature) -> Bool)
|
||||
,_doActionIfElseElseAction :: Action
|
||||
}
|
||||
| DoActionWhileThen
|
||||
{_doActionWhileThenDo :: Action
|
||||
,_doActionWhileThenCondition :: ( (World, Creature) -> Bool)
|
||||
,_doActionWhileThenThen :: Action
|
||||
}
|
||||
| DoActions
|
||||
{_doActionsList :: [Action]
|
||||
}
|
||||
| DoActionOnce
|
||||
{_doActionOnceAction :: Action
|
||||
}
|
||||
| DoActionThen
|
||||
{_doActionThenFirst :: Action
|
||||
,_doActionThenSecond :: Action
|
||||
}
|
||||
| DoGuardActions
|
||||
{_doGuardActionsList :: [( (World, Creature) -> Bool, Action, Maybe Action)]
|
||||
}
|
||||
| DoReplicateThen
|
||||
{_doReplicateThenDo :: Action
|
||||
,_doReplicateThenTimes :: Int
|
||||
,_doReplicateThenAfter :: Action
|
||||
}
|
||||
| LeadTarget
|
||||
{_leadTargetBy :: Point2
|
||||
}
|
||||
| NoAction
|
||||
| StartSentinelPost
|
||||
deriving (Generic)
|
||||
-- deriving (Eq,Ord,Show)
|
||||
data Strategy
|
||||
= Flank Int
|
||||
| Ambush Int
|
||||
| Lure Int Point2
|
||||
| Patrol [Point2]
|
||||
| ShootAt Int
|
||||
| FollowImpulses
|
||||
| WatchAndWait
|
||||
| StrategyActions [Action] Strategy
|
||||
| GetTo Point2
|
||||
| Reload
|
||||
deriving (Generic)
|
||||
-- deriving (Eq,Ord,Show)
|
||||
data Goal
|
||||
= LiveLongAndProsper
|
||||
| Kill Int
|
||||
| SentinelAt Point2 Float
|
||||
|
||||
makeLenses ''World
|
||||
makeLenses ''Cloud
|
||||
makeLenses ''Creature
|
||||
@@ -460,6 +597,9 @@ makeLenses ''ForceField
|
||||
makeLenses ''FFState
|
||||
makeLenses ''PressPlate
|
||||
makeLenses ''Button
|
||||
makeLenses ''ActionPlan
|
||||
makeLenses ''Impulse
|
||||
makeLenses ''Action
|
||||
|
||||
numColor :: Int -> Color
|
||||
numColor 0 = (1,0,0,1)
|
||||
|
||||
Reference in New Issue
Block a user