swarm-0.6.0.0: 2D resource gathering game with programmable robots
LicenseBSD-3-Clause
Safe HaskellSafe-Inferred
LanguageHaskell2010

Swarm.Game.Step.Path.Cache.DistanceLimit

Description

Handles cache invalidation if the distance limit is modified between invocations of the Path command.

Synopsis

Documentation

getDistanceLimitInvalidation Source #

Arguments

:: Location

current robot location

-> NonEmpty Location

original path

-> Maybe Integer

current limit

-> Maybe Integer

previous limit

-> Either DistanceLimitChange () 

A greater distance limit might yield a shorter path if there was a better route that just needed to venture outside of the allowed radius.

On the other hand, a smaller distance limit will not invalidate the cache so long as all cells on the path are within the new limit.

withinDistance Source #

Arguments

:: Integer

distance limit

-> Location

current robot location

-> Location

target location

-> Bool 

This function is shared between path computation logic and patch cache invalidation logic to ensure that the choice of inequality operator is consistent (e.g. < vs. <=).