-
Notifications
You must be signed in to change notification settings - Fork 4
Decisions
There's a lot of small, one-off decisions that we discuss in-person or in random Discord messages that never get documented, but should be, since they are pretty critical to the future of the project. We need to be on the same page with the technical choices we make since we have a lot of moving pieces that all need to agree with each other for this project to work. This is a space to document those choices as we remember them. We can change our minds on things later, just make sure it gets documented here, please!
- Jason Antwi-Appah
Author: Jason Antwi-Appah
Currently there are multiple data types on the server that are used to represent positions vaguely. This documents how the coordinate grid works, and what each of these types means.
^^ that image is still a little wrong, need to redo and add more clarifying stuff for coordinates. ignore this for now lol
The grid represents all the places in space that a robot can be. The grid is 12 squares wide x 12 squares tall, with the center 8 x 8 squares being used for the chessboard. The additional 2 'rings' of squares around the chess board are used to store robots in a location off the chess board when captured, or for intermediary moves where robots need to be temporarily moved off the board to create a path for other robots to move.
The grid is unitless and doesn't prescribe that each square must be of a specific physical dimension. This is so we can run in different spaces with bigger or smaller square dimensions.
On start up, each robot runs a process to determine the size of a square using the IR sensors on the bottom of the robot and align itself to the center. When moving, each robot handles translating the unitless positions and distance calculated on the server, which is relative to the grid, to IRL distance units and coordinates, which it does by using the physical square dimensions that it measured. The grid cell size isn't known to the server, and generally should only be a concern on the embedded side of things.
The origin of the grid, coordinate (0, 0)
, is at the bottom-left corner of the bottom-left square.
GridIndices
and Square
are similar to each other. Both a Square
or GridIndices
instance refers to the full area of a full grid cell. Square
is a string in algebraic chess notation, that refers to one cell on the chess board, like a1
(bottom left most cell on the chess board), or h8
(top right most cell on the chessboard). Not every GridIndices
instance can be represented as a Square
, since Square
only refers to cells on the chess board, not on the full grid.
- The bottom left most corner cell on the grid as a
GridIndices
instance is(0, 0)
. This is not representable as aSquare
. - The bottom left most corner cell on the chess board as a
GridIndices
instance is(2, 2)
. As aSquare
, this isa1
. - The top right most corner cell on the chess board as a
GridIndices
instance is(9, 9)
. As aSquare
, this ish8
. - The top right most corner cell on the grid as a
GridIndices
instance is(11, 11)
. This is not representable as aSquare
.
A Position
refers to a specific point in space.
- To place the center of a robot at the center of square
h8
, which as aGridIndices
instance is(9, 9)
, the robot'sPosition
should be set to(9.5, 9.5)
Not all the code agrees with this, so if you see something that looks out of wack with this, fix it :)