Add Read/Show instance for Creature
This commit is contained in:
+131
-127
@@ -19,13 +19,17 @@ data ActionPlan
|
||||
,_apStrategy :: Strategy
|
||||
,_apGoal :: [Goal]
|
||||
}
|
||||
newtype RandImpulse = RandImpulseList [Impulse]
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
data RandImpulse
|
||||
= RandImpulseList [Impulse]
|
||||
| RandImpulseCircMove Float
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
data Impulse
|
||||
= Move Point2
|
||||
| MoveForward Float
|
||||
| Turn Float
|
||||
| RandomTurn Float
|
||||
| RandomImpulse (State StdGen Impulse)
|
||||
| RandomImpulse RandImpulse -- (State StdGen Impulse)
|
||||
| TurnToward Point2 Float
|
||||
| MvTurnToward Point2
|
||||
| MvForward
|
||||
@@ -52,34 +56,34 @@ data Impulse
|
||||
{_impulseUseAheadPos :: P2Imp
|
||||
}
|
||||
| ImpulseNothing
|
||||
instance Show Impulse where
|
||||
show imp = case imp of
|
||||
Move p -> "Move "++shortPoint2 p
|
||||
MoveForward f -> "MoveForward "++ show f
|
||||
Turn f -> "Turn "++show f
|
||||
RandomTurn f -> "RandomTurn "++show f
|
||||
TurnToward p f -> "TurnToward "++shortPoint2 p++show f
|
||||
MvTurnToward p -> "MvTurnToward "++shortPoint2 p
|
||||
MvForward -> "MvForward"
|
||||
TurnTo p -> "TurnTo "++shortPoint2 p
|
||||
UseItem -> "UseItem"
|
||||
SwitchToItem i -> "SwitchToItem "++show i
|
||||
DropItem -> "DropItem"
|
||||
Bark sid -> "Bark "++show sid
|
||||
Melee i -> "Melee "++show i
|
||||
ChangePosture post -> "ChangePosture " ++ show post
|
||||
MakeSound sid -> "MakeSound " ++ show sid
|
||||
ChangeStrategy s -> "ChangeStrategy " ++ show s
|
||||
AddGoal g -> "AddGoal " ++ show g
|
||||
ArbitraryImpulseFunction {} -> "ArbitraryImpulseFunction"
|
||||
ArbitraryImpulse {} -> "ArbitraryImpulse"
|
||||
ArbitraryImpulseEffect {} -> "ArbitraryImpulseEffect"
|
||||
ImpulseUseTargetCID {} -> "ImpulseUseTargetCID"
|
||||
ImpulseUseTarget {} -> "ImpulseUseTarget"
|
||||
ImpulseUseAheadPos {} -> "ImpulseUseAheadPos"
|
||||
RandomImpulse {} -> "RandomImpulse"
|
||||
ImpulseNothing -> "ImpulseNothing"
|
||||
-- deriving (Eq,Ord,Show)
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
--instance Show Impulse where
|
||||
-- show imp = case imp of
|
||||
-- Move p -> "Move "++shortPoint2 p
|
||||
-- MoveForward f -> "MoveForward "++ show f
|
||||
-- Turn f -> "Turn "++show f
|
||||
-- RandomTurn f -> "RandomTurn "++show f
|
||||
-- TurnToward p f -> "TurnToward "++shortPoint2 p++show f
|
||||
-- MvTurnToward p -> "MvTurnToward "++shortPoint2 p
|
||||
-- MvForward -> "MvForward"
|
||||
-- TurnTo p -> "TurnTo "++shortPoint2 p
|
||||
-- UseItem -> "UseItem"
|
||||
-- SwitchToItem i -> "SwitchToItem "++show i
|
||||
-- DropItem -> "DropItem"
|
||||
-- Bark sid -> "Bark "++show sid
|
||||
-- Melee i -> "Melee "++show i
|
||||
-- ChangePosture post -> "ChangePosture " ++ show post
|
||||
-- MakeSound sid -> "MakeSound " ++ show sid
|
||||
-- ChangeStrategy s -> "ChangeStrategy " ++ show s
|
||||
-- AddGoal g -> "AddGoal " ++ show g
|
||||
-- ArbitraryImpulseFunction {} -> "ArbitraryImpulseFunction"
|
||||
-- ArbitraryImpulse {} -> "ArbitraryImpulse"
|
||||
-- ArbitraryImpulseEffect {} -> "ArbitraryImpulseEffect"
|
||||
-- ImpulseUseTargetCID {} -> "ImpulseUseTargetCID"
|
||||
-- ImpulseUseTarget {} -> "ImpulseUseTarget"
|
||||
-- ImpulseUseAheadPos {} -> "ImpulseUseAheadPos"
|
||||
-- RandomImpulse {} -> "RandomImpulse"
|
||||
-- ImpulseNothing -> "ImpulseNothing"
|
||||
infixr 9 `WaitThen`
|
||||
infixr 9 `DoActionThen`
|
||||
infixr 9 `DoActionWhile`
|
||||
@@ -180,101 +184,101 @@ data Action
|
||||
{_sideImpulses :: [Impulse]
|
||||
,_mainAction :: Action
|
||||
}
|
||||
deriving (Generic)
|
||||
instance Show Action where
|
||||
show act = case act of
|
||||
ActionNothing -> "ActionNothing"
|
||||
LabelAction
|
||||
{_actLabel = str
|
||||
,_actAction = subAct
|
||||
} -> str++":"++show subAct
|
||||
AimAt
|
||||
{_targetID = tid
|
||||
,_targetSeenAt = p
|
||||
} -> "AimAt tid:"++show tid++" seenAt:"++shortPoint2 p
|
||||
PathTo
|
||||
{_pathToPoint = p
|
||||
} -> "PathTo:"++shortPoint2 p
|
||||
TurnToPoint
|
||||
{_turnToPoint = p
|
||||
} -> "TurnToPoint:"++shortPoint2 p
|
||||
---- | PickupItem
|
||||
---- {_pickupItemID :: Int
|
||||
---- }
|
||||
ImpulsesList
|
||||
{_impulsesListList = iss
|
||||
} -> "ImpulsesList:"++show iss
|
||||
DoImpulses
|
||||
{_doImpulsesList = is
|
||||
} -> "DoImpulses:"++show is
|
||||
WaitThen
|
||||
{_waitThenTimer = i
|
||||
,_waitThenAction = a
|
||||
} -> "WaitThen timer:"++show i++" act:"++show a
|
||||
DoActionWhile
|
||||
{_doActionWhileCondition = _
|
||||
,_doActionWhileAction = a
|
||||
} -> "DoActionWhile (function) act:"++show a
|
||||
DoActionWhilePartial
|
||||
{_doActionWhilePartial = partact
|
||||
,_doActionWhileCondition = _
|
||||
,_doActionWhileAction = a
|
||||
} -> "DoActionWhilePartial partAct:"++show partact++" resetAct:"++show a
|
||||
DoActionIf
|
||||
{_doActionIfCondition = _
|
||||
,_doActionIfAction = a
|
||||
} -> "DoActionIf act:"++show a
|
||||
DoActionIfElse
|
||||
{_doActionIfElseIfAction = ifa
|
||||
,_doActionIfElseCondition = _
|
||||
,_doActionIfElseElseAction = elsea
|
||||
} -> "DoActionIfElse ifa:"++show ifa++" elsea:"++show elsea
|
||||
DoActionWhileInterrupt
|
||||
{_doActionWhileThenDo = whilea
|
||||
,_doActionWhileThenCondition = _
|
||||
,_doActionWhileThenThen = thena
|
||||
} -> "DoActionWhileInterrupt whilea:" ++show whilea++" interrupta:"++show thena
|
||||
DoActions
|
||||
{_doActionsList = as
|
||||
} -> "DoActions " ++ foldMap show as
|
||||
DoActionThen
|
||||
{_doActionThenFirst = a1
|
||||
,_doActionThenSecond = a2
|
||||
} -> "DoActionThen " ++ show a1 ++ " then:" ++ show a2
|
||||
---- | DoGuardActions
|
||||
---- {_doGuardActionsList :: [( (World, Creature) -> Bool, Action, Maybe Action)]
|
||||
---- }
|
||||
DoReplicate
|
||||
{_doReplicateTimes = i
|
||||
,_doReplicateAction = a
|
||||
} -> "DoReplicate times:" ++ show i ++ " act:"++ show a
|
||||
DoReplicatePartial
|
||||
{_partialAction = pa
|
||||
,_doReplicateTimes = i
|
||||
,_doReplicateAction = ra
|
||||
} -> "DoReplicatePartial pa:" ++ show pa ++ " times:" ++ show i ++ " reset:"++ show ra
|
||||
LeadTarget
|
||||
{_leadTargetBy = p
|
||||
} -> "LeadTarget by:"++ show p
|
||||
NoAction -> "NoAction"
|
||||
StartSentinelPost -> "StartSentinelPost"
|
||||
UseTarget
|
||||
{_useTarget = _
|
||||
} -> "UseTarget func"
|
||||
UseSelf
|
||||
{_useSelf = _
|
||||
} -> "UseSelf func"
|
||||
UseAheadPos
|
||||
{_useAheadPos = _
|
||||
} -> "UseAheadPos func"
|
||||
UseMvTargetPos
|
||||
{_useMvTargetPos = _
|
||||
} -> "UseMvTargetPos func"
|
||||
ArbitraryAction {} -> "ArbitraryAction func"
|
||||
DoImpulsesAlongside
|
||||
{_sideImpulses = is
|
||||
,_mainAction = a
|
||||
} -> "DoImpulsesAlongside sideImpulses:"++show is ++ " mainA:"++show a
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
--instance Show Action where
|
||||
-- show act = case act of
|
||||
-- ActionNothing -> "ActionNothing"
|
||||
-- LabelAction
|
||||
-- {_actLabel = str
|
||||
-- ,_actAction = subAct
|
||||
-- } -> str++":"++show subAct
|
||||
-- AimAt
|
||||
-- {_targetID = tid
|
||||
-- ,_targetSeenAt = p
|
||||
-- } -> "AimAt tid:"++show tid++" seenAt:"++shortPoint2 p
|
||||
-- PathTo
|
||||
-- {_pathToPoint = p
|
||||
-- } -> "PathTo:"++shortPoint2 p
|
||||
-- TurnToPoint
|
||||
-- {_turnToPoint = p
|
||||
-- } -> "TurnToPoint:"++shortPoint2 p
|
||||
------ | PickupItem
|
||||
------ {_pickupItemID :: Int
|
||||
------ }
|
||||
-- ImpulsesList
|
||||
-- {_impulsesListList = iss
|
||||
-- } -> "ImpulsesList:"++show iss
|
||||
-- DoImpulses
|
||||
-- {_doImpulsesList = is
|
||||
-- } -> "DoImpulses:"++show is
|
||||
-- WaitThen
|
||||
-- {_waitThenTimer = i
|
||||
-- ,_waitThenAction = a
|
||||
-- } -> "WaitThen timer:"++show i++" act:"++show a
|
||||
-- DoActionWhile
|
||||
-- {_doActionWhileCondition = _
|
||||
-- ,_doActionWhileAction = a
|
||||
-- } -> "DoActionWhile (function) act:"++show a
|
||||
-- DoActionWhilePartial
|
||||
-- {_doActionWhilePartial = partact
|
||||
-- ,_doActionWhileCondition = _
|
||||
-- ,_doActionWhileAction = a
|
||||
-- } -> "DoActionWhilePartial partAct:"++show partact++" resetAct:"++show a
|
||||
-- DoActionIf
|
||||
-- {_doActionIfCondition = _
|
||||
-- ,_doActionIfAction = a
|
||||
-- } -> "DoActionIf act:"++show a
|
||||
-- DoActionIfElse
|
||||
-- {_doActionIfElseIfAction = ifa
|
||||
-- ,_doActionIfElseCondition = _
|
||||
-- ,_doActionIfElseElseAction = elsea
|
||||
-- } -> "DoActionIfElse ifa:"++show ifa++" elsea:"++show elsea
|
||||
-- DoActionWhileInterrupt
|
||||
-- {_doActionWhileThenDo = whilea
|
||||
-- ,_doActionWhileThenCondition = _
|
||||
-- ,_doActionWhileThenThen = thena
|
||||
-- } -> "DoActionWhileInterrupt whilea:" ++show whilea++" interrupta:"++show thena
|
||||
-- DoActions
|
||||
-- {_doActionsList = as
|
||||
-- } -> "DoActions " ++ foldMap show as
|
||||
-- DoActionThen
|
||||
-- {_doActionThenFirst = a1
|
||||
-- ,_doActionThenSecond = a2
|
||||
-- } -> "DoActionThen " ++ show a1 ++ " then:" ++ show a2
|
||||
------ | DoGuardActions
|
||||
------ {_doGuardActionsList :: [( (World, Creature) -> Bool, Action, Maybe Action)]
|
||||
------ }
|
||||
-- DoReplicate
|
||||
-- {_doReplicateTimes = i
|
||||
-- ,_doReplicateAction = a
|
||||
-- } -> "DoReplicate times:" ++ show i ++ " act:"++ show a
|
||||
-- DoReplicatePartial
|
||||
-- {_partialAction = pa
|
||||
-- ,_doReplicateTimes = i
|
||||
-- ,_doReplicateAction = ra
|
||||
-- } -> "DoReplicatePartial pa:" ++ show pa ++ " times:" ++ show i ++ " reset:"++ show ra
|
||||
-- LeadTarget
|
||||
-- {_leadTargetBy = p
|
||||
-- } -> "LeadTarget by:"++ show p
|
||||
-- NoAction -> "NoAction"
|
||||
-- StartSentinelPost -> "StartSentinelPost"
|
||||
-- UseTarget
|
||||
-- {_useTarget = _
|
||||
-- } -> "UseTarget func"
|
||||
-- UseSelf
|
||||
-- {_useSelf = _
|
||||
-- } -> "UseSelf func"
|
||||
-- UseAheadPos
|
||||
-- {_useAheadPos = _
|
||||
-- } -> "UseAheadPos func"
|
||||
-- UseMvTargetPos
|
||||
-- {_useMvTargetPos = _
|
||||
-- } -> "UseMvTargetPos func"
|
||||
-- ArbitraryAction {} -> "ArbitraryAction func"
|
||||
-- DoImpulsesAlongside
|
||||
-- {_sideImpulses = is
|
||||
-- ,_mainAction = a
|
||||
-- } -> "DoImpulsesAlongside sideImpulses:"++show is ++ " mainA:"++show a
|
||||
|
||||
-- deriving (Eq,Ord,Show)
|
||||
data Strategy
|
||||
@@ -293,13 +297,13 @@ data Strategy
|
||||
| Reload
|
||||
| Flee
|
||||
| MeleeStrike
|
||||
deriving (Generic,Show)
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
-- deriving (Eq,Ord,Show)
|
||||
data Goal
|
||||
= LiveLongAndProsper
|
||||
| Kill Int
|
||||
| SentinelAt Point2 Float
|
||||
deriving (Show)
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
makeLenses ''ActionPlan
|
||||
makeLenses ''Impulse
|
||||
makeLenses ''Action
|
||||
|
||||
Reference in New Issue
Block a user