class documentation
Represents a 2D grid with traversal functionality.
Method | __init__ |
Initializes the Grid with given dimensions. |
Method | calculate |
Calculates the current (x, y) offset in physical space. |
Method | decrement |
Moves the current position one step upward. |
Method | decrement |
Moves the current position one step to the left. |
Method | increment |
Moves the current position one step downward. |
Method | increment |
Moves the current position one step to the right. |
Instance Variable | column |
Number of columns in the grid. (int) |
Instance Variable | current |
Current horizontal position (column index). (int) |
Instance Variable | current |
Current vertical position (row index). (int) |
Instance Variable | row |
Number of rows in the grid. (int) |
Moves the current position one step upward.
Wraps to the previous column if at the top of a column. Raises an error if moving beyond the top-left corner of the grid.
Raises | |
ValueError | If the position goes below (0, 0). |
Moves the current position one step to the left.
Wraps to the previous row if at the start of a row. Raises an error if moving beyond the top-left corner of the grid.
Raises | |
ValueError | If the position goes below (0, 0). |
Moves the current position one step downward.
Wraps to the next column if the end of a column is reached. Raises an error if moving beyond the bottom-right corner of the grid.
Raises | |
ValueError | If the position exceeds the grid bounds. |
Moves the current position one step to the right.
Wraps to the next row if the end of a row is reached. Raises an error if moving beyond the bottom-right corner of the grid.
Raises | |
ValueError | If the position exceeds the grid bounds. |