swarm-0.5.0.0: 2D resource gathering game with programmable robots
LicenseBSD-3-Clause
Safe HaskellSafe-Inferred
LanguageHaskell2010

Swarm.Game.Scenario.Objective.Graph

Description

Utilities for performing graph analysis on Objective prerequisites

Synopsis

Documentation

data ObjectiveId Source #

This is only needed for constructing a Graph, which requires all nodes to have a key.

Constructors

Label (Signed ObjectiveLabel) 
Ordinal Int

for unlabeled objectives

Instances

Instances details
ToJSON ObjectiveId Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective.Graph

Generic ObjectiveId Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective.Graph

Associated Types

type Rep ObjectiveId :: Type -> Type #

Show ObjectiveId Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective.Graph

Eq ObjectiveId Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective.Graph

Ord ObjectiveId Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective.Graph

type Rep ObjectiveId Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective.Graph

type Rep ObjectiveId = D1 ('MetaData "ObjectiveId" "Swarm.Game.Scenario.Objective.Graph" "swarm-0.5.0.0-6qXEbhCmuXA4wRndqqhBu" 'False) (C1 ('MetaCons "Label" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Signed ObjectiveLabel))) :+: C1 ('MetaCons "Ordinal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int)))

data GraphInfo Source #

Instances

Instances details
ToJSON GraphInfo Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective.Graph

Generic GraphInfo Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective.Graph

Associated Types

type Rep GraphInfo :: Type -> Type #

Show GraphInfo Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective.Graph

ToSample GraphInfo Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective.Graph

type Rep GraphInfo Source # 
Instance details

Defined in Swarm.Game.Scenario.Objective.Graph

type Rep GraphInfo = D1 ('MetaData "GraphInfo" "Swarm.Game.Scenario.Objective.Graph" "swarm-0.5.0.0-6qXEbhCmuXA4wRndqqhBu" '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]))))

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.

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.

Orphan instances