License | BSD-3-Clause |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Swarm.Game.Robot.Concrete
Description
Support for instantiated robots.
Synopsis
- machine :: Lens' Robot CESK
- activityCounts :: Lens' Robot ActivityCounts
- robotLog :: Lens' Robot (Seq LogEntry)
- robotLogUpdated :: Lens' Robot Bool
- waitingUntil :: Robot -> Maybe TickNumber
- getResult :: Robot -> Maybe Value
- isActive :: Robot -> Bool
- wantsToStep :: TickNumber -> Robot -> Bool
- instantiateRobot :: Maybe CESK -> RID -> TRobot -> Robot
Lenses
activityCounts :: Lens' Robot ActivityCounts Source #
Diagnostic and operational tracking of CESK steps or other activity
robotLog :: Lens' Robot (Seq LogEntry) Source #
The robot's own private message log, most recent message last.
Messages can be added both by explicit use of the Log
command,
and by uncaught exceptions. Stored as a Seq
so that
we can efficiently add to the end and also process from beginning
to end. Note that updating via this lens will also set the
robotLogUpdated
.
robotLogUpdated :: Lens' Robot Bool Source #
Has the robotLog
been updated since the last time it was
viewed?
Query
waitingUntil :: Robot -> Maybe TickNumber Source #
The time until which the robot is waiting, if any.
getResult :: Robot -> Maybe Value Source #
Get the result of the robot's computation if it is finished.
wantsToStep :: TickNumber -> Robot -> Bool Source #
Active robots include robots that are waiting; wantsToStep
is
true if the robot actually wants to take another step right now
(this is a subset of active robots).
Utilities
instantiateRobot :: Maybe CESK -> RID -> TRobot -> Robot Source #
Instantiate a robot template to make it into a concrete robot, by
providing a robot ID. Concrete robots also require a location;
if the robot template didn't have a location already, just set
the location to (0,0) by default. If you want a different location,
set it via trobotLocation
before calling instantiateRobot
.
If a machine is not supplied (i.e. Nothing
), will fallback to any
program specified in the template robot.