Author: theCalcaholic
In this challenge, you take control over Karel, a little robot, which has to solve various tasks.
- functions (limited understanding sufficient)
- loops (task 02 and later)
- virtual environments (venv) (recommended, not required)
The following instructions assume that you are currently in the beginner/karel directory.
Install the package python3-tk. For example, on Ubuntu:
apt install python3-tkNothing to do
All challenges require the essentials to be set up!
Run the karel script from this repositories bin directory (double clicking it should work as well):
bin/karel.shRun the karel script from this repositories bin directory (double clicking it should work as well):
bin/karel.batA dialog will open, showing you all the Karel tasks. Select the one you want to run and confirm. Now you will be presented two windows: One shows the state of the map after you have solved the task (Karel Goal) and the other one shows the solution runner, where you can see your script in action.
You will find multiple python scripts in the solutions folder. These act as solution templates and contain further instructions on how to solve each task.
Within all solutions, you are given access to a number of functions which control the behaviour of Karel the robot:
| Karel Commands | ||
|---|---|---|
move() |
right_is_clear() |
facing_east() |
turn_left() |
right_is_blocked() |
not_facing_east() |
put_beeper() |
beepers_present() |
facing_west() |
pick_beeper() |
no_beepers_present() |
not_facing_west() |
front_is_clear() |
beepers_in_bag() |
facing_south() |
front_is_blocked() |
no_beepers_in_bag() |
not_facing_south() |
left_is_clear() |
facing_north() |
paint_corner(color) |
left_is_blocked() |
not_facing_north() |
corner_color_is(color) |
For most tasks, only a subset of these commands will be required. This subset will usually be explained within the solution template.
After you have written your code you first need to run (and save) it in your programming software before you can open and run the visual game.
Further information on Karel (and more examples) can be found here
