License | BSD-3-Clause |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Swarm.Game.State.Landscape
Description
Synopsis
- data Landscape
- type SubworldDescription = (SubworldName, ([IndexedTRobot], Seed -> WorldFun Int Entity))
- worldNavigation :: Lens' Landscape (Navigation (Map SubworldName) Location)
- multiWorld :: Lens' Landscape (MultiWorld Int Entity)
- worldScrollable :: Lens' Landscape Bool
- terrainAndEntities :: Lens' Landscape TerrainEntityMaps
- recognizerAutomatons :: Lens' Landscape (RecognizerAutomatons RecognizableStructureContent Entity)
- initLandscape :: GameStateConfig -> Landscape
- mkLandscape :: ScenarioLandscape -> NonEmpty SubworldDescription -> Seed -> Landscape
- buildWorldTuples :: ScenarioLandscape -> NonEmpty SubworldDescription
- genMultiWorld :: NonEmpty SubworldDescription -> Seed -> MultiWorld Int Entity
- buildWorld :: TerrainEntityMaps -> WorldDescription -> ([IndexedTRobot], Seed -> WorldFun Int Entity)
- genRobotTemplates :: ScenarioLandscape -> NonEmpty (a, ([(Int, TRobot)], b)) -> [TRobot]
Documentation
type SubworldDescription = (SubworldName, ([IndexedTRobot], Seed -> WorldFun Int Entity)) Source #
Lenses
worldNavigation :: Lens' Landscape (Navigation (Map SubworldName) Location) Source #
Includes a Map
of named locations and an
"edge list" (graph) that maps portal entrances to exits
multiWorld :: Lens' Landscape (MultiWorld Int Entity) Source #
The current state of the world (terrain and entities only; robots
are stored in the robotMap
). Int
is used instead of
TerrainType
because we need to be able to store terrain values in
unboxed tile arrays.
worldScrollable :: Lens' Landscape Bool Source #
Whether the world map is supposed to be scrollable or not.
terrainAndEntities :: Lens' Landscape TerrainEntityMaps Source #
The catalogs of all terrain and entities that the game knows about.
recognizerAutomatons :: Lens' Landscape (RecognizerAutomatons RecognizableStructureContent Entity) Source #
Recognition engine for predefined structures
Utilities
initLandscape :: GameStateConfig -> Landscape Source #
Create an record that is empty except for system-provided entities.
mkLandscape :: ScenarioLandscape -> NonEmpty SubworldDescription -> Seed -> Landscape Source #
buildWorld :: TerrainEntityMaps -> WorldDescription -> ([IndexedTRobot], Seed -> WorldFun Int Entity) Source #
Take a world description, parsed from a scenario file, and turn it into a list of located robots and a world function.
genRobotTemplates :: ScenarioLandscape -> NonEmpty (a, ([(Int, TRobot)], b)) -> [TRobot] Source #
Returns a list of robots, ordered by decreasing preference to serve as the "base".
Rules for selecting the "base" robot:
What follows is a thorough description of how the base choice is made as of the most recent study of the code. This level of detail is not meant to be public-facing.
For an abbreviated explanation, see the "Base robot" section of the Scenario Authoring Guide.
Precedence rules
Prefer those robots defined with a
loc
(robotLocation
) in the scenario file- If multiple robots define a
loc
, use the robot that is defined first within the scenario file. - Note that if a robot is both given a
loc
AND is specified in the world map, then two instances of the robot shall be created. The instance with theloc
shall be preferred as the base.
- If multiple robots define a
Fall back to robots generated from templates via the map and palette.
- If multiple robots are specified in the map, prefer the one that is defined first within the scenario file.
- If multiple robots are instantiated from the same template, then prefer the one with a lower-indexed subworld. Note that the root subworld is always first.
- If multiple robots instantiated from the same template are in the same subworld, then prefer the one closest to the upper-left of the screen, with higher rows given precedence over columns (i.e. first in row-major order).