28 Nov 2016 21:30:45 UTC
- Distribution: Karel
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (492 / 0 / 10)
- KwaliteeBus factor: 1
- 96.60% Coverage
- License: artistic_2
- Perl: v5.10.0
- Activity24 month
- Download (21.43KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionCHOROBA E. Choroba
Basic robot class. It represents a robot wihtout a grid.
- my $robot = 'Karel::Robot'->new
The constructor. It can take one parameter:
parser. Its value should be a parser object, by default an instance of
- $robot->set_grid($grid, $x, $y, $direction)
Applies the Karel::Robot::WithGrid role to the $robot.
$gridmust be a
Karel::Gridinstance, $x and $y denote the position of the robot in the grid. Optional $direction is one of
N E S W(for North, East, South, and West), defaults to
The class to which the robot is reblessed after obraining the grid. By default, it's the robot's class plus
- $robot->load_grid( [ file | handle ] => '...' )
Loads grid from the given source. You can specify a scalar reference as
file, too. The format of the input is as follows:
# karel 4 2 WWWWWW W v W W1w W WWWWWW
The first line specifies width and height of the grid. An ASCII map of the grid follows with the following symbols:
W outer wall w inner wall space blank 1 .. 9 marks
The robot's position and direction is denoted by either of
^ > v <preceding the cell in which the robot should start. In the example above, the robots starts at coordinates 4, 1 and faces South.
- $commands = $robot->knows($command_name)
If the robot knows the command, returns its definition; dies otherwise.
Teaches the robot new commands. Dies if the definitions contain unknown commands.