NAME
Karel::Grid
DESCRIPTION
Represents the map in which the robot moves.
METHODS
- 'Karel::Grid'->new
-
my $grid = 'Karel::Grid'->new( x => 10, y => 12 );
The constructor creates an empty grid of the given size.
- $grid->x, $grid->y
-
my ($x, $y) = map $grid->$_, qw( x y );
Returns the size of the grid.
- $grid->at($x, $y)
-
Returns a space if there's nothing at the given position. For marks, it returns 1 - 9. For walls, it returns "W" (outer walls) or "w" (inner walls).
- $grid->build_wall($x, $y)
-
Builds a wall ("w") at the given coordinates.
- $gird->remove_wall($x, $y)
-
Removes a wall ("w") from the given coordinates. Dies if there's no wall.
- $grid->drop_mark($x, $y)
-
Drop a mark at the given position. There must be an empty place or less than 9 marks, otherwise the method dies.
- $grid->pick_mark($x, $y)
-
Pick up a mark from the given position. Dies if there's no mark.
- $grid->clear($x, $y)
-
Set the given position to empty (" ").