sneks.engine.core.cell module
- class sneks.engine.core.cell.Cell(x: int, y: int)
Bases:
object
Represents a single cell on the game board. They can be used as reference points for getting neighboring cells, like:
>>> cell = Cell(1, 1) >>> cell.get_left() Cell(0, 1) >>> cell.get_relative_neighbor(2, 3) Cell(3, 4) >>> cell.get_neighbor(Direction.DOWN) Cell(1, 0)
Finally, it can be used to calculate distance between cells:
>>> cell_a = Cell(0, 0) >>> cell_b = Cell(1, 0) >>> cell_a.get_distance(cell_b) 1.0
- x: int
- y: int
- get_relative_neighbor(x_offset: int, y_offset: int) Cell
Returns the cell with coordinates offset by the specified parameters.
- Parameters:
x_offset – the amount to offset this cell’s x by
y_offset – the amount to offset this cell’s y by
- Returns:
the cell at
(self.x + x_offset, self.y + y_offset)