-
-
28 Nov 2016 21:30:45 UTC
- Distribution: Karel
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues
- Testers (492 / 0 / 10)
- Kwalitee
Bus factor: 1- 96.60% Coverage
- License: artistic_2
- Perl: v5.10.0
- Activity
24 month- Tools
- Download (21.43KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Carp
- Clone
- Cwd
- Exporter
- List::Util
- Marpa::R2
- Module::Load
- Moo
- Syntax::Construct
- constant
- namespace::clean
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Karel::Robot
DESCRIPTION
Basic robot class. It represents a robot wihtout a grid.
METHODS
- my $robot = 'Karel::Robot'->new
-
The constructor. It can take one parameter:
parser
. Its value should be a parser object, by default an instance ofKarel::Parser
. - $robot->set_grid($grid, $x, $y, $direction)
-
Applies the Karel::Robot::WithGrid role to the $robot.
$grid
must be aKarel::Grid
instance, $x and $y denote the position of the robot in the grid. Optional $direction is one ofN E S W
(for North, East, South, and West), defaults toN
. - class_with_grid
-
The class to which the robot is reblessed after obraining the grid. By default, it's the robot's class plus
::WithGrid
. - $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.
- $robot->learn($program)
-
Teaches the robot new commands. Dies if the definitions contain unknown commands.
Module Install Instructions
To install Karel, copy and paste the appropriate command in to your terminal.
cpanm Karel
perl -MCPAN -e shell install Karel
For more information on module installation, please visit the detailed CPAN module installation guide.