Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Utilities for performing graph analysis on Objective prerequisites
Synopsis
- data ObjectiveId
- = Label (Signed ObjectiveLabel)
- | Ordinal Int
- data GraphInfo = GraphInfo {
- actualGraph :: Graph
- isAcyclic :: Bool
- sccInfo :: [SCC Objective]
- nodeIDs :: [ObjectiveId]
- getConstFromSigned :: Signed a -> a
- getNegatedIds :: [Objective] -> Map ObjectiveLabel Objective
- getObjectivesById :: [Objective] -> Map ObjectiveLabel Objective
- assignIds :: [Objective] -> Map ObjectiveId Objective
- type Edges = [(Objective, ObjectiveId, [ObjectiveId])]
- makeGraph :: Edges -> Graph
- makeGraphEdges :: [Objective] -> Edges
- isAcyclicGraph :: [SCC Objective] -> Bool
- makeGraphInfo :: ObjectiveCompletion -> GraphInfo
Documentation
data ObjectiveId Source #
This is only needed for constructing a Graph, which requires all nodes to have a key.
Label (Signed ObjectiveLabel) | |
Ordinal Int | for unlabeled objectives |
Instances
GraphInfo | |
|
Instances
ToJSON GraphInfo Source # | |
Defined in Swarm.Game.Scenario.Objective.Graph | |
Generic GraphInfo Source # | |
Show GraphInfo Source # | |
type Rep GraphInfo Source # | |
Defined in Swarm.Game.Scenario.Objective.Graph type Rep GraphInfo = D1 ('MetaData "GraphInfo" "Swarm.Game.Scenario.Objective.Graph" "swarm-0.3.0.0-DptGDjHvXlqJcJyQcOsuxZ" 'False) (C1 ('MetaCons "GraphInfo" 'PrefixI 'True) ((S1 ('MetaSel ('Just "actualGraph") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Graph) :*: S1 ('MetaSel ('Just "isAcyclic") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool)) :*: (S1 ('MetaSel ('Just "sccInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [SCC Objective]) :*: S1 ('MetaSel ('Just "nodeIDs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [ObjectiveId])))) |
getConstFromSigned :: Signed a -> a Source #
getNegatedIds :: [Objective] -> Map ObjectiveLabel Objective Source #
Collect all of the constants that have a negation. This is necessary for enumerating all of the distinct nodes when constructing a Graph, as we treat a constant and its negation as distinct nodes.
assignIds :: [Objective] -> Map ObjectiveId Objective Source #
Uses the textual labels for those objectives that have them, and assigns arbitrary integer IDs for the remaining.
Only necessary for constructing a Graph.
type Edges = [(Objective, ObjectiveId, [ObjectiveId])] Source #
makeGraph :: Edges -> Graph Source #
NOTE: Based strictly on the goal labels, the graph could potentially contain a cycle, if there exist mutually-exclusive goals. That is, if goal A depends on the NOT of "goal B". Goal B could then also depend on "NOT Goal A" (re-enforcing the mutual-exclusivity), or it could mandate a completion order, e.g.: Goal A and Goal B are simultaneously available to pursue. However, if the player completes Goal B first, then it closes off the option to complete Goal A. However, if Goal A is completed first, then the user is also allowed to complete Goal B.
To avoid a "cycle" in this circumstance, A needs to exist as a distinct node from "NOT A" in the graph.
makeGraphEdges :: [Objective] -> Edges Source #