Location & Vector
- class sorrel.location.Location(*coords)
A custom subclass of tuple that represents a location in the environment.
This class provides additional functionality for calculations, such as addition and scalar multiplication. Since it is a subclass of tuple, Location objects are immutable.
Examples
>>> Location(1, 2, 3) + Location(2, 4, 8) Location(3, 6, 11) >>> Location(2, 4) * 3 Location(6, 12, 0)
- class sorrel.location.Vector(forward: int, right: int, backward: int = 0, left: int = 0, layer: int = 0, direction: int = 0)
A class that represents vectors. Handy for calculations involving beams and more.
- forward
The number of steps forward.
- Type:
int
- right
The number of steps right.
- Type:
int
- backward
(Optional) The number of steps backward. Since negative vectors are supported, this can be carried by the forward value.
- Type:
int
- left
(Optional) The number of steps left. Since negative vectors are supported, this can be carried by the right value.
- Type:
int
- layer
(Optional) The number of layers up (positive) or down (negative).
- Type:
int
- direction
(Optional) A compass direction. 0 = NORTH, 1 = EAST, 2 = SOUTH, 3 = WEST.
- Type:
int
- __add__(other) Vector
Add two vectors together.
The vectors must be with respect to the same direction.
- compute() Location
Given a direction being faced and a number of paces forward / right / backward / left, compute the location.
- rotate(new_direction: int)
Rotate the vector to face a new direction.