| License | BSD-3-Clause |
|---|---|
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Swarm.Game.Scenario.Topography.Structure.Recognition.Type
Description
Structure recognizer types.
See overview of the structure recognizer feature in Swarm.Game.Scenario.Topography.Structure.Recognition.Precompute.
The following structure template shall be used to illustrate roles of the types in this module:
cdc aab cdc
Synopsis
- type OriginalName = Text
- type AtomicKeySymbol a = Maybe a
- type SymbolSequence a = [AtomicKeySymbol a]
- data StructureSearcher b a = StructureSearcher {
- automaton2D :: AutomatonInfo a (SymbolSequence a) (StructureWithGrid b a)
- needleContent :: SymbolSequence a
- singleRowItems :: NonEmpty (SingleRowEntityOccurrences b a)
- data PositionWithinRow b a = PositionWithinRow {
- _position :: Int32
- structureRow :: StructureRow b a
- data SingleRowEntityOccurrences b a = SingleRowEntityOccurrences {
- myRow :: StructureRow b a
- myEntity :: a
- entityOccurrences :: NonEmpty (PositionWithinRow b a)
- expandedOffsets :: InspectionOffsets
- data StructureRow b a = StructureRow {
- wholeStructure :: StructureWithGrid b a
- rowIndex :: Int32
- rowContent :: SymbolSequence a
- data NamedOriginal a = NamedOriginal {
- getName :: OriginalName
- orig :: a
- data StructureWithGrid b a = StructureWithGrid {}
- data RotationalSymmetry
- data SymmetryAnnotatedGrid a = SymmetryAnnotatedGrid {
- namedGrid :: a
- symmetry :: RotationalSymmetry
- data StructureInfo b a = StructureInfo {}
- data InspectionOffsets = InspectionOffsets {}
- data AutomatonInfo en k v = AutomatonInfo {}
- participatingEntities :: forall en k v en. Lens (AutomatonInfo en k v) (AutomatonInfo en k v) (HashSet en) (HashSet en)
- inspectionOffsets :: forall en k v. Lens' (AutomatonInfo en k v) InspectionOffsets
- automaton :: forall en k v k v. Lens (AutomatonInfo en k v) (AutomatonInfo en k v) (StateMachine k v) (StateMachine k v)
- data RecognizerAutomatons b a = RecognizerAutomatons {
- _originalStructureDefinitions :: Map OriginalName (StructureInfo b a)
- _automatonsByEntity :: HashMap a (AutomatonInfo a (AtomicKeySymbol a) (StructureSearcher b a))
- originalStructureDefinitions :: forall b a. Lens' (RecognizerAutomatons b a) (Map OriginalName (StructureInfo b a))
- automatonsByEntity :: forall b a. Lens' (RecognizerAutomatons b a) (HashMap a (AutomatonInfo a (AtomicKeySymbol a) (StructureSearcher b a)))
- data FoundStructure b a = FoundStructure {}
- genOccupiedCoords :: FoundStructure b a -> [Cosmic Location]
Documentation
type OriginalName = Text Source #
A NamedStructure has its own newtype name (StructureName), but we
standardize on Text here to avoid parameterizing our NamedOriginal
datatype on bespoke name types.
type AtomicKeySymbol a = Maybe a Source #
A "needle" consisting of a single cell within the haystack (a row of cells) to be searched.
Example
A single entity a in the row:
aab
type SymbolSequence a = [AtomicKeySymbol a] Source #
A "needle" consisting row of cells within the haystack (a sequence of rows) to be searched.
Example
The complete row:
aab
data StructureSearcher b a Source #
This is returned as a value of the 1-D searcher. It contains search automatons customized to the 2-D structures that may possibly contain the row found by the 1-D searcher.
Constructors
| StructureSearcher | |
Fields
| |
data PositionWithinRow b a Source #
Position specific to a single entity within a horizontal row.
Example
For entity b within the row:
aab
Its _position is 2.
Constructors
| PositionWithinRow | |
Fields
| |
data SingleRowEntityOccurrences b a Source #
Constructors
| SingleRowEntityOccurrences | |
Fields
| |
data StructureRow b a Source #
A a specific row within a particular structure.
Example
For the second occurrence of cdc within the structure:
cdc aab cdc
it's rowIndex is 2.
The two type parameters, b and a, correspond
to StructureCells and Entity, respectively.
Constructors
| StructureRow | |
Fields
| |
data NamedOriginal a Source #
This wrapper facilitates naming the original structure (i.e. the "payload" for recognition) for the purpose of both UI display and internal uniqueness, while remaining agnostic to its internals.
Constructors
| NamedOriginal | |
Fields
| |
Instances
| Show a => Show (NamedOriginal a) Source # | |
Defined in Swarm.Game.Scenario.Topography.Structure.Recognition.Type Methods showsPrec :: Int -> NamedOriginal a -> ShowS # show :: NamedOriginal a -> String # showList :: [NamedOriginal a] -> ShowS # | |
| Eq a => Eq (NamedOriginal a) Source # | |
Defined in Swarm.Game.Scenario.Topography.Structure.Recognition.Type Methods (==) :: NamedOriginal a -> NamedOriginal a -> Bool # (/=) :: NamedOriginal a -> NamedOriginal a -> Bool # | |
data StructureWithGrid b a Source #
The original definition of a structure, bundled with its grid of cells having been extracted for convenience.
The two type parameters, b and a, correspond
to StructureCells and Entity, respectively.
Constructors
| StructureWithGrid | |
Fields
| |
Instances
| (Eq b, Eq a) => Eq (StructureWithGrid b a) Source # | |
Defined in Swarm.Game.Scenario.Topography.Structure.Recognition.Type Methods (==) :: StructureWithGrid b a -> StructureWithGrid b a -> Bool # (/=) :: StructureWithGrid b a -> StructureWithGrid b a -> Bool # | |
data RotationalSymmetry Source #
Constructors
| NoSymmetry | Aka 1-fold symmetry |
| TwoFold | Equivalent under rotation by 180 degrees |
| FourFold | Equivalent under rotation by 90 degrees |
Instances
| Show RotationalSymmetry Source # | |
Defined in Swarm.Game.Scenario.Topography.Structure.Recognition.Type Methods showsPrec :: Int -> RotationalSymmetry -> ShowS # show :: RotationalSymmetry -> String # showList :: [RotationalSymmetry] -> ShowS # | |
| Eq RotationalSymmetry Source # | |
Defined in Swarm.Game.Scenario.Topography.Structure.Recognition.Type Methods (==) :: RotationalSymmetry -> RotationalSymmetry -> Bool # (/=) :: RotationalSymmetry -> RotationalSymmetry -> Bool # | |
data SymmetryAnnotatedGrid a Source #
Constructors
| SymmetryAnnotatedGrid | |
Fields
| |
Instances
| Show a => Show (SymmetryAnnotatedGrid a) Source # | |
Defined in Swarm.Game.Scenario.Topography.Structure.Recognition.Type Methods showsPrec :: Int -> SymmetryAnnotatedGrid a -> ShowS # show :: SymmetryAnnotatedGrid a -> String # showList :: [SymmetryAnnotatedGrid a] -> ShowS # | |
data StructureInfo b a Source #
Structure definitions with precomputed metadata for consumption by the UI
Constructors
| StructureInfo | |
Fields
| |
data InspectionOffsets Source #
For all of the rows that contain a given entity (and are recognized by a single automaton), compute the left-most and right-most position within the row that the given entity may occur.
This determines how far to the left and to the right our search of the world cells needs to begin and end, respectively.
The Semigroup instance always grows in extent, taking the minimum
of the leftward offsets and the maximum of the rightward offsets.
Constructors
| InspectionOffsets | |
Fields
| |
Instances
data AutomatonInfo en k v Source #
Each automaton shall be initialized to recognize a certain subset of structure rows, that may either all be within one structure, or span multiple structures.
Constructors
| AutomatonInfo | |
Fields | |
Instances
participatingEntities :: forall en k v en. Lens (AutomatonInfo en k v) (AutomatonInfo en k v) (HashSet en) (HashSet en) Source #
inspectionOffsets :: forall en k v. Lens' (AutomatonInfo en k v) InspectionOffsets Source #
automaton :: forall en k v k v. Lens (AutomatonInfo en k v) (AutomatonInfo en k v) (StateMachine k v) (StateMachine k v) Source #
data RecognizerAutomatons b a Source #
The complete set of data needed to identify applicable structures, based on a just-placed entity.
Constructors
| RecognizerAutomatons | |
Fields
| |
Instances
originalStructureDefinitions :: forall b a. Lens' (RecognizerAutomatons b a) (Map OriginalName (StructureInfo b a)) Source #
automatonsByEntity :: forall b a. Lens' (RecognizerAutomatons b a) (HashMap a (AutomatonInfo a (AtomicKeySymbol a) (StructureSearcher b a))) Source #
data FoundStructure b a Source #
Final output of the search process.
These are the elements that are stored in the FoundRegistry.
The two type parameters, b and a, correspond
to StructureCells and Entity, respectively.
Constructors
| FoundStructure | |
Fields | |
Instances
| (Eq b, Eq a) => Eq (FoundStructure b a) Source # | |
Defined in Swarm.Game.Scenario.Topography.Structure.Recognition.Type Methods (==) :: FoundStructure b a -> FoundStructure b a -> Bool # (/=) :: FoundStructure b a -> FoundStructure b a -> Bool # | |
| (Eq b, Eq a) => Ord (FoundStructure b a) Source # | Ordering is by increasing preference between simultaneously completed structures. The preference heuristic is for:
Since the natural order of coordinates increases as described,
we need to invert it with |
Defined in Swarm.Game.Scenario.Topography.Structure.Recognition.Type Methods compare :: FoundStructure b a -> FoundStructure b a -> Ordering # (<) :: FoundStructure b a -> FoundStructure b a -> Bool # (<=) :: FoundStructure b a -> FoundStructure b a -> Bool # (>) :: FoundStructure b a -> FoundStructure b a -> Bool # (>=) :: FoundStructure b a -> FoundStructure b a -> Bool # max :: FoundStructure b a -> FoundStructure b a -> FoundStructure b a # min :: FoundStructure b a -> FoundStructure b a -> FoundStructure b a # | |
genOccupiedCoords :: FoundStructure b a -> [Cosmic Location] Source #
Yields coordinates that are occupied by an entity of a placed structure. Cells within the rectangular bounds of the structure that are unoccupied are not included.