An up-to-date look at free software and its makers
Projects on the Move
Python inventor Guido van Rossum is known to have a good sense of humor and probably had a good laugh when he heard about the Guido van Robot project. If you are learning how to program, or would like to teach others, this software gives you a light-hearted introduction.
Perhaps you've heard of Python creator Guido van Rossum, but you might not be familiar with Karel the Robot. Almost 30 years ago, Richard Pattis invented a robot called Karel and presented him to the general public in his 1981 book Karel the Robot: A Gentle Introduction for the Art of Programming [1]. This virtual character has the advantage of living in a simple world in which his biggest challenges are maneuvering around obstacles – namely, walls – and picking up beepers. To tackle his tasks, Karel can be programmed in a simple language with an understandable instruction set and without variables.
The original Karel the Robot programming language was based on Pascal, but many variants have been invented since then to give learners a simpler approach to other programming languages. One of these variants is Guido van Robot, a character in the long-standing tradition of simulated, programmable robots, whose task it is to introduce newcomers to Python [2] (Figure 1). As a tribute to Python's Dutch inventor, Guido van Rossum [3], the students who programmed the Python teaching language in 2001 called it Guido van Robot [4]. Version 3.3 is now available.
Guido – the robot that is, not the Python inventor – can understand five commands: move, turnleft, pickbeeper, putbeeper, and turnoff. The first two commands tell the robot to move or turn left; pick and put tell it to pick up and drop beepers, and turnoff quits the program (Figure 2).
Besides the imperatives listed here, Guido – like most other programming languages – gives users loops and conditions. The latter are introduced by the key words if, elif, and else; the while key word supports conditional execution. The do X command tells Guido to repeat the following command block a certain number of times.
View of the World
To be able to react to its environment, Guido van Robot uses 18 test instructions to explore its world, including front_is_clear, left_is_clear, right_is_clear, and front_is_blocked, that define the existence of walls. The objects lying around on the playing field are referred to as beepers. The instructions next_to_a_beeper and any_beepers_in_beeper_bag and corresponding negatives tell Guido where the beepers are.
The last remaining test category contains the facing_north and not_facing_north commands and variants, which use the other three directions instead of north. Typical Guido van Robot instructions look like:
if next_to_a_beeper: pickbeeper elif front_is_clear : move
What makes Guido van Robot so attractive to newcomers is that the environment has its own interface, comprising the Code Editor, World Editor, and Guido's World area. Python newcomers can watch their robot tour the world while their program is running.
Define-It-Yourself
If you are not happy with the existing instruction set, you can define your own instructions based on it. Put the define Name keyword at the start of a definition block, which can contain simple instructions, loops, and conditions. Here's an example for a step backward:
define back: do 2: turnleft move do 2: turnleft
What Guido van Robot now lacks is an environment through which the program can guide him.
Fortunately, the software package includes three worlds: boring, escape1, and maze1. The first lacks barriers, which is a good thing in normal circumstances, but here, its lack of events makes it unsuitable for testing algorithms. escape1 is a more interesting prospect; a world that comprises a room with an exit. Trying to get to the exit as quickly as possible is a more useful programming task.
The third environment is a small maze, as you might have guessed from the name, maze1, in which Guido finds the first beeper.
If you want to set your robot on more ambitious tasks, you easily can define your own worlds. For this, the World Editor understands the WALL command.
In a similar way, you can use the Robot keyword to set the starting position for Guido van Robot. To feed the robot in your world, you need to use the Beepers keyword to lay a trail of numbered beepers.
The first two arguments define the position of the object and are followed by an arbitrary number that the program uses to label the beeper.
After designing a world and writing a robot program, you can press the Execute button to launch the robot. The code editor highlights the current line, making it easy to follow loops and conditions. If everything is happening too fast for you to follow, you can press the Step button to step through the instructions one by one.
If you are familiar with Python or any other programming language, you will easily master programming Guido van Robot and its numerous relatives. Programming the robot can be fun even for serious programmers. The effortless way in which you can maneuver the robot through small worlds is a rewarding experience.
Of course, Guido van Robot is suitable for teaching, which is what the project is really about (Figure 2). If you never have tried programming, this gives you a fun approach to the buzz language Python and could be your ticket to entering the wacky world of coding.
Infos
- Karel the Robot: http://www.mtsu.edu/~untch/karel/book.html
- Python: http://www.python.org
- Guido van Rossum: http://www.python.org/~guido
- Guido van Robot: http://gvr.sourceforge.net
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.