What is an avenue in a karel world




In this section, we will present other examples that will help us continue thinking about the principle of algorithmic decomposition and, furthermore, how to think of solutions that are general enough to address different versions of the same problem.


Some examples presented in this tutorial were adapted from “Karel the robot learns Java” (Eric Roberts, 2005).




Fixing the street again


In the previous section, we proposed the following program to solve the problem of filling the holes in the street:

This program works for worlds with streets of any length. However, it would not work if the holes were not evenly spaced as we initially assumed. It would be better to have a more general program that works under these conditions:



The world can have streets of any length.



The holes can be located at any position along the street, without restrictions on the number or spacing.



Some holes may already be filled, so Karel should not put a
thing
in them.



An example of this type of world is:



To solve this problem, instead of starting each iteration with a move, we should first check if there is a hole where Karel is standing. If there is, Karel should fill it in if

More Basic Karel


Karel can navigate a world by moving and turning left within it. Karel can also take balls and put balls down. Recall that these are the only four commands Karel knows:

Karel resides in a boxed-in world. Let's review the basic components of Karel's world.

Karel's World

Karel's world is a grid composed of
walls
,
streets
, and
avenues
.

Walls:


Walls
block Karel's movement. Walls include the borders of a world as well as any lines running through the world.



Karel cannot move through walls! If Karel attempts a command while directly in front of a wall, Karel will
crash
into it.

Streets:

A
street
is a
row
in the grid.



The
5th row
, or
5th street
, is highlighted in the example world above.

Avenues:

An
avenue
is a
column
in the grid.



The
8th column
, or
8th avenue
, is highlighted in the example world above.

Karel's Direction

Karel can face one of four directions at any given time -
north
,
east
,
south
, or
west
. The direction Karel is facing determines which direction Karel will move. If Karel is facing north, a command will make Karel move up. If Karel is facing east, a command will make Ka

About Karel's World


What is Karel
Karel is a robot living in a simple world represented on your computer screen.

Karel (facing north)


A little picture of Karel's world.

How can Karel get about in his world?
Karel's world is crisscrossed by horizontal
streets
and vertical
avenues
which are represented by lines on your computer screen. Karel can only stand at
corners
where a street and avenue intersect. He can move and turn about, but he must stay on the streets and avenues and can only stop at corners.
What directions can Karel face?
Karel can face in any of the directions
north
(toward the top of the screen),
south
(toward the bottom),
east
(toward the right), and
west
(toward the left).
What objects appear in Karel's World
There are two other kinds of things in Karel's world besides Karel:
walls
, and
beepers
.
What are walls?
The walls in Karel's world are made of neutronium (an impenetrable metal). They appear as dar obstructions between street corners in Karel's world.

Wall Section (east-west)


What are beepers?
Beepers are small platic cones that make a quiet beeping sound. They may appear at street corners and may be picked up or plac


This page provides an
overview of Karel's world and what he can do
.

You may also want to read a reference guide that describes the details of the commands and functions Karel understands and/or a reference guide for the .

Karel's World:


General Comments

Karel lives in a flat world with the standard north, south, east, and west compass points. The world is bounded on all four sides by boundaries. Karel cannot bump into these walls; if he tries to move into one, he will crash.

Crisscrossing the world are horizontal
streets
(running east-west) and vertical
avenues
(running north-south). An
intersection
(or street corner or corner) is located wherever a street and avenue intersect. Karel can be positioned on any corner, facing one of the four compass points. Both streets and avenues are numbered; consequently each intersection may be identified by its street and avenue numbers.

The corner of 1st Street and 1st Avenue is named the
origin
. This is the most southwesterly corner in Karel's world. Street numbers increase as Karel travels east and avenue numbers increase as Karel travels north.

Karel's Locat