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

Swarm.Game.Scenario

Description

Scenarios are standalone worlds with specific starting and winning conditions, which can be used both for building interactive tutorials and for standalone puzzles and scenarios.

Synopsis

WorldDescription

data PCell e Source #

A single cell in a world map, which contains a terrain value, and optionally an entity and robot. It is parameterized on the Entity type to facilitate less stateful versions of the Entity type in rendering scenario data.

Instances

Instances details
ToJSON Cell Source # 
Instance details

Defined in Swarm.Game.Scenario.Topography.Cell

ToJSON CellPaintDisplay Source # 
Instance details

Defined in Swarm.Game.Scenario.Topography.Cell

Show e => Show (PCell e) Source # 
Instance details

Defined in Swarm.Game.Scenario.Topography.Cell

Methods

showsPrec :: Int -> PCell e -> ShowS #

show :: PCell e -> String #

showList :: [PCell e] -> ShowS #

Eq e => Eq (PCell e) Source # 
Instance details

Defined in Swarm.Game.Scenario.Topography.Cell

Methods

(==) :: PCell e -> PCell e -> Bool #

(/=) :: PCell e -> PCell e -> Bool #

FromJSONE (EntityMap, RobotMap) Cell Source # 
Instance details

Defined in Swarm.Game.Scenario.Topography.Cell

FromJSONE (EntityMap, RobotMap) (NamedStructure (Maybe (PCell Entity))) Source # 
Instance details

Defined in Swarm.Game.Scenario.Topography.Structure

FromJSONE (EntityMap, RobotMap) (PStructure (Maybe (PCell Entity))) Source # 
Instance details

Defined in Swarm.Game.Scenario.Topography.Structure

FromJSONE (WorldMap, InheritedStructureDefs, EntityMap, RobotMap) WorldDescription Source # 
Instance details

Defined in Swarm.Game.Scenario.Topography.WorldDescription

type Cell = PCell Entity Source #

A single cell in a world map, which contains a terrain value, and optionally an entity and robot.

type IndexedTRobot = (Int, TRobot) Source #

A robot template paired with its definition's index within the Scenario file

Scenario

Fields

scenarioVersion :: Lens' Scenario Int Source #

The version number of the scenario schema. Currently, this should always be 1, but it is ignored. In the future, this may be used to convert older formats to newer ones, or simply to print a nice error message when we can't read an older format.

scenarioName :: Lens' Scenario Text Source #

The name of the scenario.

scenarioAuthor :: Lens' Scenario (Maybe Text) Source #

The author of the scenario.

scenarioDescription :: Lens' Scenario (Document Syntax) Source #

A high-level description of the scenario, shown e.g. in the menu.

scenarioCreative :: Lens' Scenario Bool Source #

Whether the scenario should start in creative mode.

scenarioSeed :: Lens' Scenario (Maybe Int) Source #

The seed used for the random number generator. If Nothing, use a random seed / prompt the user for the seed.

scenarioAttrs :: Lens' Scenario [CustomAttr] Source #

Custom attributes defined in the scenario.

scenarioEntities :: Lens' Scenario EntityMap Source #

Any custom entities used for this scenario.

scenarioRecipes :: Lens' Scenario [Recipe Entity] Source #

Any custom recipes used in this scenario.

scenarioKnown :: Lens' Scenario [Text] Source #

List of entities that should be considered "known", so robots do not have to scan them.

scenarioWorlds :: Lens' Scenario (NonEmpty WorldDescription) Source #

The subworlds of the scenario. The "root" subworld shall always be at the head of the list, by construction.

scenarioNavigation :: Lens' Scenario (Navigation (Map SubworldName) Location) Source #

Waypoints and inter-world portals

scenarioRobots :: Lens' Scenario [TRobot] Source #

The starting robots for the scenario. Note this should include the base.

scenarioObjectives :: Lens' Scenario [Objective] Source #

A sequence of objectives for the scenario (if any).

scenarioSolution :: Lens' Scenario (Maybe ProcessedTerm) Source #

An optional solution of the scenario, expressed as a program of type cmd a. This is useful for automated testing of the win condition.

scenarioStepsPerTick :: Lens' Scenario (Maybe Int) Source #

Optionally, specify the maximum number of steps each robot may take during a single tick.

Loading from disk

loadScenario :: (Has (Throw SystemFailure) sig m, Has (Lift IO) sig m) => FilePath -> EntityMap -> WorldMap -> m (Scenario, FilePath) Source #

Load a scenario with a given name from disk, given an entity map to use. This function is used if a specific scenario is requested on the command line.

loadScenarioFile :: (Has (Throw SystemFailure) sig m, Has (Lift IO) sig m) => EntityMap -> WorldMap -> FilePath -> m Scenario Source #

Load a scenario from a file.