swarm-0.7.0.0: 2D resource gathering game with programmable robots
LicenseBSD-3-Clause
Safe HaskellNone
LanguageHaskell2010

Swarm.Game.State.Landscape

Description

 
Synopsis

Documentation

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.

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

  1. Prefer those robots defined with a loc (robotLocation) in the scenario file

    1. If multiple robots define a loc, use the robot that is defined first within the scenario file.
    2. 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 the loc shall be preferred as the base.
  1. Fall back to robots generated from templates via the map and palette.

    1. If multiple robots are specified in the map, prefer the one that is defined first within the scenario file.
    2. 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.
    3. 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).