Copyright | Brent Yorgey |
---|---|
License | BSD-3-Clause |
Maintainer | byorgey@gmail.com |
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 Objective
- objectiveGoal :: Lens' Objective [Text]
- objectiveCondition :: Lens' Objective ProcessedTerm
- data Cell = Cell {
- cellTerrain :: TerrainType
- cellEntity :: Maybe Entity
- cellRobots :: [TRobot]
- data WorldDescription = WorldDescription {}
- data Scenario
- scenarioVersion :: Lens' Scenario Int
- scenarioName :: Lens' Scenario Text
- scenarioAuthor :: Lens' Scenario (Maybe Text)
- scenarioDescription :: Lens' Scenario Text
- scenarioCreative :: Lens' Scenario Bool
- scenarioSeed :: Lens' Scenario (Maybe Int)
- scenarioEntities :: Lens' Scenario EntityMap
- scenarioRecipes :: Lens' Scenario [Recipe Entity]
- scenarioKnown :: Lens' Scenario [Text]
- scenarioWorld :: Lens' Scenario WorldDescription
- scenarioRobots :: Lens' Scenario [TRobot]
- scenarioObjectives :: Lens' Scenario [Objective]
- scenarioSolution :: Lens' Scenario (Maybe ProcessedTerm)
- scenarioStepsPerTick :: Lens' Scenario (Maybe Int)
- loadScenario :: (Has (Lift IO) sig m, Has (Throw Text) sig m) => String -> EntityMap -> m (Scenario, FilePath)
- loadScenarioFile :: (Has (Lift IO) sig m, Has (Throw Text) sig m) => EntityMap -> FilePath -> m Scenario
- getScenarioPath :: FilePath -> IO (Maybe FilePath)
Objectives
An objective is a condition to be achieved by a player in a scenario.
Instances
FromJSON Objective Source # | |
ToJSON Objective Source # | |
Defined in Swarm.Game.Scenario | |
Generic Objective Source # | |
Show Objective Source # | |
Eq Objective Source # | |
type Rep Objective Source # | |
Defined in Swarm.Game.Scenario type Rep Objective = D1 ('MetaData "Objective" "Swarm.Game.Scenario" "swarm-0.1.1.0-ARNQOCsge3P61nb92PmOB2" 'False) (C1 ('MetaCons "Objective" 'PrefixI 'True) (S1 ('MetaSel ('Just "_objectiveGoal") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [Text]) :*: S1 ('MetaSel ('Just "_objectiveCondition") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ProcessedTerm))) |
objectiveGoal :: Lens' Objective [Text] Source #
An explanation of the goal of the objective, shown to the player during play. It is represented as a list of paragraphs.
objectiveCondition :: Lens' Objective ProcessedTerm Source #
A winning condition for the objective, expressed as a
program of type cmd bool
. By default, this program will be
run to completion every tick (the usual limits on the number
of CESK steps per tick do not apply).
WorldDescription
A single cell in a world map, which contains a terrain value, and optionally an entity and robot.
Cell | |
|
data WorldDescription Source #
A description of a world parsed from a YAML file.
Instances
Show WorldDescription Source # | |
Defined in Swarm.Game.Scenario showsPrec :: Int -> WorldDescription -> ShowS # show :: WorldDescription -> String # showList :: [WorldDescription] -> ShowS # | |
Eq WorldDescription Source # | |
Defined in Swarm.Game.Scenario (==) :: WorldDescription -> WorldDescription -> Bool # (/=) :: WorldDescription -> WorldDescription -> Bool # |
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 Text 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.
scenarioKnown :: Lens' Scenario [Text] Source #
List of entities that should be considered "known", so robots do not have to scan them.
scenarioWorld :: Lens' Scenario WorldDescription Source #
The starting world for the scenario.
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 (Lift IO) sig m, Has (Throw Text) sig m) => String -> EntityMap -> 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.