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

Swarm.Game.Scenario.Topography.Navigation.Util

Description

 
Synopsis

Documentation

orientationBasedRelativePosition :: Robot -> Cosmic Location -> Maybe (V2 Int32) Source #

Computes the relative offset vector between a Robot and a Location (presumed to be in the same subworld, though the contrary will not result in failure), then re-interpret that vector based on the Robot's current orientation.

If the robot is not oriented in a cardinal direction, returns Nothing.

Re-orientation semantics

Given a displacement vector (x, y) where:

  • positive x-coordinate represents east
  • negative x-coordinate represents west
  • positive y-coordinate represents north
  • negative y-coordinate represents south

the re-interpreted vector (x', y') becomes:

  • positive x'-coordinate represents right
  • negative x'-coordinate represents left
  • positive y'-coordinate represents forward
  • negative y'-coordinate represents back