Naming convention

R.U.R. is a 1920 science fiction play by the Czech writer Karel Čapek. R.U.R. stands for Rossumovi Univerzální Roboti (Rossum’s Universal Robots). However, the English phrase Rossum’s Universal Robots had been used as the subtitle in the Czech original. It premiered on 25 January 1921 and introduced the word robot to the English language and to science fiction as a whole.

reference: wikipedia:R.U.R.

[Note that Karel the robot was thus named by R. Pattis in honour of Karel Čapek.]

Since the goal of Reeborg's World is to allow students to run their own programs, name clashes have to be avoided between functions created for Reeborg's World and those created by the student. The imperfect solution I have chosen is to try, as much as possible, to use a single global object or namespace, RUR, originally inspired by the 1920 science fiction play but which can stand for Reeborg the Used Robot and is also valid in French as le Robot Usagé Reeborg.

You have already seen this namespace being used in the first chapter with

RUR.set_world_size(3, 3)
RUR.add_final_position("house", 3, 1)
RUR.add_wall("east", 1, 1)

You can see all the relevant functions included in the Application Programming Interface (API) for creating world. Please note that there are likely more functions belonging to the RUR namespace than those documented on that site. As a general rule, you should not create additional functions belonging to the RUR namespace.

[info] Finding out more

Currently, if you executehelp_js(RUR) in a JavaScript program, you will see all the names belonging to that namespace. The name help_js is subject to change.

A simple pattern

To create interesting worlds without using the menu-driven editor, at the very least you need to know:

  • The name of things
  • If a thing of a particular type can be found at a given location
  • How to add a thing of a particular type at a given location
  • Possibly, how to remove a thing of a particular type at a given location.

The basic naming convention to do such actions follows the following pattern:

  • RUR.is_TYPE(name, x, y)
  • RUR.add_TYPE(name, x, y)
  • RUR.remove_TYPE(name, x, y)

    Possible values for TYPE include the following:

    • background_tile
    • bridge
    • decorative_object
    • object
    • obstacle
    • overlay [todo: implement this]
    • pushable
    • wall

Thus, we could have:

  • RUR.is_background_tile("grass", 3, 4) would indicate whether or not a "grass" tile was used as a background tile at location (3, 4).
  • RUR.add_object("token", 2, 5) adds a "token" as an object (that can be picked up) at location (2, 5).
  • RUR.remove_obstacle("vertical_fence", 1, 5); etc.

As we saw with RUR.set_world_size(3, 3), some functions do not follow this pattern. A few other cases, such as "final position" which we saw, also have only one of the three basic methods (add/is/remove) but not the others.

When three is not enough

In some cases, the basic three arguments, name, x, and y, are not sufficient. To deal with such cases in a general way, a fourth argument can be added; this argument will be a Python dict or, if using Javascript, a simple object. Some specific examples are provided later.

Available things and general help

To view what things are available, you can execute a program with a single line of code.


If you are using a non-English version, an extra column is shown using the translated name (if available); this translated name is the one that would be needed in a user-written program, e.g. prend("feuille") instead of take("leaf").

Instead of entering this line in the editor, you can use the Python REPL mode; this is something I find useful when I look things up as it leaves the code in the editor unchanged.

There is a separate function to show existing robot images:


Note about the word "thing"

In Reeborg's World, the word object has been used for many years to describe "things" with which Reeborg can interact and is used in some functions like object_here(). The word type refers to a certain classification of "things" described above. The word artefact is used in the code for many basic functions. If these were not already used, I would have chosen any one of them instead of using "thing", as in show_all_objects() instead of show_all_things()... However, even if you have a better suggestion, it is probably too late to make changes without annoying existing users.

results matching ""

    No results matching ""