travel To
Move agent from its current position in space to destination at constant velocity. The traversal takes distance / velocity simulated time units; the projection is updated to interpolated intermediate positions every stepSize coordinate-units of travel so concurrent spatial queries (space.within(...), space.neighborsOf(...)) reflect the moving agent's current position at step granularity.
Pattern (discrete-step continuous motion):
inner class Vehicle : Agent("v") {
val script: KSLProcess = process(isDefaultProcess = true) {
travelTo(this@Vehicle, mySpace, destination = Point2D(50.0, 50.0), velocity = 2.0)
}
}Granularity tradeoff: smaller stepSize gives finer-grained position updates at the cost of more events on the calendar. The parameter is in distance (coordinate units), not time, so the spatial fidelity is the same regardless of velocity — a fast vehicle and a slow vehicle using stepSize = 0.5 both update every half-unit of travel. Pick a step that matches whatever spatial resolution matters: cell size for grid-aligned movement, collision radius for obstacle checks, pedestrian shoulder width for crowd queries.
Edge cases:
If
current == destination(already at the target) the function returns immediately withdistance == 0.0.If
totalDistance <= stepSize, a single delay-and-move is used (no interpolation needed).The final position is set exactly to destination (not the accumulated interpolation result, which could drift due to floating-point error over many steps).
Limitations (deliberate v1 scope):
Uninterruptible. Once started, the travel runs to completion. To support "change direction mid-travel," wrap the call site in your own logic (e.g., short travels chained together) or use the existing
delay+ manualmoveTopattern.No collision detection. The agent passes through other agents and obstacles. For obstacle-aware navigation use GridGraph to plan a path of waypoints, then
travelToeach.Constant velocity. Accelerate / decelerate isn't a primitive. Compose with multiple
travelTocalls at different velocities if needed.
Return
a TravelResult describing the completed motion.
Parameters
the moving agent; must be a member of space's context and already placed somewhere.
the projection in which the motion occurs.
target coordinates.
speed in coordinate-units-per-simulated-time; must be positive.
interpolation interval in coordinate units of travel; must be positive.