License | BSD-3-Clause |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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
- data PCell e = Cell {
- cellTerrain :: TerrainType
- cellEntity :: Erasable e
- cellRobots :: [IndexedTRobot]
- type Cell = PCell Entity
- data PWorldDescription e = WorldDescription {
- offsetOrigin :: Bool
- scrollable :: Bool
- palette :: WorldPalette e
- ul :: Location
- area :: [[PCell e]]
- navigation :: Navigation Identity WaypointName
- worldName :: SubworldName
- worldProg :: Maybe (TTerm '[] (World CellVal))
- type WorldDescription = PWorldDescription Entity
- type IndexedTRobot = (Int, TRobot)
- data Scenario = Scenario {
- _scenarioVersion :: Int
- _scenarioName :: Text
- _scenarioAuthor :: Maybe Text
- _scenarioDescription :: Document Syntax
- _scenarioCreative :: Bool
- _scenarioSeed :: Maybe Int
- _scenarioAttrs :: [CustomAttr]
- _scenarioEntities :: EntityMap
- _scenarioRecipes :: [Recipe Entity]
- _scenarioKnown :: [Text]
- _scenarioWorlds :: NonEmpty WorldDescription
- _scenarioNavigation :: Navigation (Map SubworldName) Location
- _scenarioRobots :: [TRobot]
- _scenarioObjectives :: [Objective]
- _scenarioSolution :: Maybe ProcessedTerm
- _scenarioStepsPerTick :: Maybe Int
- scenarioVersion :: Lens' Scenario Int
- scenarioName :: Lens' Scenario Text
- scenarioAuthor :: Lens' Scenario (Maybe Text)
- scenarioDescription :: Lens' Scenario (Document Syntax)
- scenarioCreative :: Lens' Scenario Bool
- scenarioSeed :: Lens' Scenario (Maybe Int)
- scenarioAttrs :: Lens' Scenario [CustomAttr]
- scenarioEntities :: Lens' Scenario EntityMap
- scenarioRecipes :: Lens' Scenario [Recipe Entity]
- scenarioKnown :: Lens' Scenario [Text]
- scenarioWorlds :: Lens' Scenario (NonEmpty WorldDescription)
- scenarioNavigation :: Lens' Scenario (Navigation (Map SubworldName) Location)
- scenarioRobots :: Lens' Scenario [TRobot]
- scenarioObjectives :: Lens' Scenario [Objective]
- scenarioSolution :: Lens' Scenario (Maybe ProcessedTerm)
- scenarioStepsPerTick :: Lens' Scenario (Maybe Int)
- loadScenario :: (Has (Throw SystemFailure) sig m, Has (Lift IO) sig m) => FilePath -> EntityMap -> WorldMap -> m (Scenario, FilePath)
- loadScenarioFile :: (Has (Throw SystemFailure) sig m, Has (Lift IO) sig m) => EntityMap -> WorldMap -> FilePath -> m Scenario
- getScenarioPath :: Has (Lift IO) sig m => FilePath -> m (Maybe FilePath)
- loadStandaloneScenario :: (Has (Throw SystemFailure) sig m, Has (Lift IO) sig m) => FilePath -> m (Scenario, (WorldMap, EntityMap, [Recipe Entity]))
WorldDescription
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.
Cell | |
|
Instances
ToJSON Cell Source # | |
Defined in Swarm.Game.Scenario.Topography.Cell | |
ToJSON CellPaintDisplay Source # | |
Defined in Swarm.Game.Scenario.Topography.Cell toJSON :: CellPaintDisplay -> Value # toEncoding :: CellPaintDisplay -> Encoding # toJSONList :: [CellPaintDisplay] -> Value # toEncodingList :: [CellPaintDisplay] -> Encoding # | |
Show e => Show (PCell e) Source # | |
Eq e => Eq (PCell e) Source # | |
FromJSONE (EntityMap, RobotMap) Cell Source # | |
FromJSONE (EntityMap, RobotMap) (NamedStructure (Maybe (PCell Entity))) Source # | |
Defined in Swarm.Game.Scenario.Topography.Structure | |
FromJSONE (EntityMap, RobotMap) (PStructure (Maybe (PCell Entity))) Source # | |
Defined in Swarm.Game.Scenario.Topography.Structure | |
FromJSONE (WorldMap, InheritedStructureDefs, EntityMap, RobotMap) WorldDescription Source # | |
type Cell = PCell Entity Source #
A single cell in a world map, which contains a terrain value, and optionally an entity and robot.
data PWorldDescription e Source #
A description of a world parsed from a YAML file. This type is parameterized to accommodate Cells that utilize a less stateful Entity type.
WorldDescription | |
|
Instances
ToJSON WorldDescriptionPaint Source # | |
Defined in Swarm.Game.Scenario.Topography.WorldDescription toJSON :: WorldDescriptionPaint -> Value # toEncoding :: WorldDescriptionPaint -> Encoding # toJSONList :: [WorldDescriptionPaint] -> Value # toEncodingList :: [WorldDescriptionPaint] -> Encoding # | |
Show e => Show (PWorldDescription e) Source # | |
Defined in Swarm.Game.Scenario.Topography.WorldDescription showsPrec :: Int -> PWorldDescription e -> ShowS # show :: PWorldDescription e -> String # showList :: [PWorldDescription e] -> ShowS # | |
FromJSONE (WorldMap, InheritedStructureDefs, EntityMap, RobotMap) WorldDescription Source # | |
type IndexedTRobot = (Int, TRobot) Source #
A robot template paired with its definition's index within the Scenario file
Scenario
A Scenario
contains all the information to describe a
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.
scenarioDescription :: Lens' Scenario (Document Syntax) Source #
A high-level description of the scenario, shown e.g. in the menu.
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.
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.