| License | BSD-3-Clause |
|---|---|
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Swarm.Game.Device
Description
A device is an entity that provides capabilities.
Some capabilities have a cost to exercise. Items will be consumed from the inventory for invoking a command that utilizes a given capability.
Synopsis
- type SingleEntityCapabilities e = Capabilities (ExerciseCost e)
- type MultiEntityCapabilities e en = Capabilities (NonEmpty (DeviceUseCost e en))
- newtype Capabilities e = Capabilities {
- getMap :: Map Capability e
- data DeviceUseCost e en = DeviceUseCost {
- device :: e
- useCost :: ExerciseCost en
- newtype ExerciseCost e = ExerciseCost {}
- data CommandsAndCost e = CommandsAndCost {}
- getCapabilitySet :: Capabilities e -> Set Capability
- zeroCostCapabilities :: Set Capability -> SingleEntityCapabilities e
- commandsForDeviceCaps :: SingleEntityCapabilities e -> Capabilities (CommandsAndCost e)
Documentation
type SingleEntityCapabilities e = Capabilities (ExerciseCost e) Source #
Records an ExerciseCost, i.e. list of consumed ingredients, per capability that can be exercised. This represents information about a single entity/device, which can provide multiple capabilities (with a different exercise cost for each).
type MultiEntityCapabilities e en = Capabilities (NonEmpty (DeviceUseCost e en)) Source #
Records a list of devices capable of providing each capability;
along with each device is recorded the ExerciseCost needed to use
that device to achieve the given capability.
See DeviceUseCost for explanation of type parameters.
newtype Capabilities e Source #
The 'Capabilities e' wrapper type stores information of type e for each
of some set of capabilities.
For example, e could be a list of ingredients needed to exercise a
capability, or a set of devices capable of providing a capability.
Constructors
| Capabilities | |
Fields
| |
Instances
data DeviceUseCost e en Source #
A device paired with a cost to use it.
At scenario parse time, the type parameters e and en will stand for
Entity and EntityName.
This is because ExerciseCost is a member of the Entity datatype, and
therefore can only refer to another Entity by name before all Entitys
are parsed.
However, after parse time, we are able to look up actual Entity objects
by name, and therefore can instantiate ExerciseCost with Entity as
the type parameter.
Then the two type parameters of DeviceUseCost are both of Entity type.
Constructors
| DeviceUseCost | |
Fields
| |
Instances
newtype ExerciseCost e Source #
Exercising a capability may have a cost, in the form of entities that must be consumed each time it is used.
Constructors
| ExerciseCost | |
Fields | |
Instances
data CommandsAndCost e Source #
A nonempty list of commands together with an exercise cost for using any of them (typically these will be a list of commands all requiring the same capability).
Constructors
| CommandsAndCost | |
Fields | |
getCapabilitySet :: Capabilities e -> Set Capability Source #
Get the set of capabilities about which we are storing information.
zeroCostCapabilities :: Set Capability -> SingleEntityCapabilities e Source #
Create a default SingleEntityCapabilities map for a device which provides capabilities with no associated costs.
commandsForDeviceCaps :: SingleEntityCapabilities e -> Capabilities (CommandsAndCost e) Source #
Given mapping from capabilities to their exercise costs provided by a single device, turn it into an mapping from capabilities to their exercise cost and enabled commands.
NOTE: Because each Const is mapped to at most one
Capability by the constCaps function, we know that
a given Const will not appear more than once as a value in the Map produced by
this function, i.e. for the capabilities provided by a single Entity
(SingleEntityCapabilities).