License | BSD-3-Clause |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Swarm.Game.Step.Path.Type
Description
Types for shortest-path-finding and logging path-cache invalidation events.
By convention, a [Location]
does not include the
starting location, whereas a NonEmpty Location
does.
Consequentially, an empty [Location]
implies that
the robot's current location is already at the goal location.
A gratuitous number of sum types are defined here to facilitate explainability of caching behavior via logs.
Synopsis
- maxLogEntries :: Int
- data PathfindingParameters a = PathfindingParameters {}
- data CachePreservationMode
- data CacheLogEntry = CacheLogEntry {
- robot :: RID
- event :: CacheEvent
- data CacheRetrievalAttempt
- data CacheEvent
- data DistanceLimitChange
- data DifferentArgument
- data CacheRetreivalInapplicability
- data InvalidationReason
- emptyPathCache :: PathCaching
- data PathfindingTarget
- = LocationTarget Location
- | EntityTarget EntityName
- newtype TailMap = TailMap (Map Location [Location])
- data CachedPath = CachedPath {
- originalPath :: NonEmpty Location
- locations :: TailMap
- data PathfindingCache = PathfindingCache {
- invocationParms :: PathfindingParameters SubworldName
- walkabilityInfo :: WalkabilityContext
- targetLoc :: Location
- cachedPath :: CachedPath
- data PathCaching = PathCaching {
- _pathCachingRobots :: IntMap PathfindingCache
- _pathCachingLog :: RingBuffer CacheLogEntry
- pathCachingRobots :: Lens' PathCaching (IntMap PathfindingCache)
- pathCachingLog :: Lens' PathCaching (RingBuffer CacheLogEntry)
Documentation
maxLogEntries :: Int Source #
data PathfindingParameters a Source #
This is parameterized on the starting location, as we may either want to:
- provide the planar start location (when first computing the path), or
- suppress it and only propagate the subworld name (when retrieving from cache), which precludes the downstream possibility of accidentally mixing up the planar location of the target with the current robot location.
Constructors
PathfindingParameters | |
Fields
|
Instances
data CachePreservationMode Source #
It is possible for the cache to be unaffected by certain events, or the cache may modified without fully recomputing the shortest path.
Constructors
Unmodified | |
PathTruncated |
Instances
data CacheLogEntry Source #
Constructors
CacheLogEntry | |
Fields
|
Instances
data CacheRetrievalAttempt Source #
Instances
data CacheEvent Source #
Certain events can obligate the cache to be completely invalidated, or partially or fully preserved.
Constructors
Invalidate InvalidationReason | |
Preserve CachePreservationMode | |
RetrievalAttempt CacheRetrievalAttempt |
Instances
data DistanceLimitChange Source #
Constructors
LimitIncreased | |
PathExceededLimit |
Instances
data DifferentArgument Source #
Instances
data CacheRetreivalInapplicability Source #
Reasons why we cannot re-use a precomputed path
from the cache upon re-invoking the Path
command
Constructors
NotCached | |
DifferentArg DifferentArgument | |
PositionOutsidePath |
Instances
data InvalidationReason Source #
Reasons for cache being invalidated
Constructors
TargetEntityAddedOutsidePath | |
TargetEntityRemoved | |
UnwalkableRemoved | |
UnwalkableOntoPath | |
NonexistentRobot |
Instances
data PathfindingTarget Source #
Shortest paths can either be computed to the nearest entity of a given type or to a specific location.
Constructors
LocationTarget Location | |
EntityTarget EntityName | Note: navigation to entities does not benefit from the distance heuristic optimization of the A* algorithm (but see #1568) |
Instances
Facilitates lookup of any shortest path to a particular goal cell, given a location that already lies on a shortest path.
Instances
ToJSON TailMap Source # | |
Generic TailMap Source # | |
Show TailMap Source # | |
Eq TailMap Source # | |
type Rep TailMap Source # | |
Defined in Swarm.Game.Step.Path.Type type Rep TailMap = D1 ('MetaData "TailMap" "Swarm.Game.Step.Path.Type" "swarm-0.6.0.0-ERx1HMcRMba59aI2b6aNrS-swarm-engine" 'True) (C1 ('MetaCons "TailMap" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Location [Location])))) |
data CachedPath Source #
Constructors
CachedPath | |
Fields
|
Instances
data PathfindingCache Source #
A per-robot cache for the path
command.
Constructors
PathfindingCache | |
Fields
|
Instances
data PathCaching Source #
Constructors
PathCaching | |
Fields
|
pathCachingRobots :: Lens' PathCaching (IntMap PathfindingCache) Source #
All the RIDs of robots that are storing a cached path that may require invalidation.
pathCachingLog :: Lens' PathCaching (RingBuffer CacheLogEntry) Source #
Event log for cache invalidation