For computer science teachers

Robot, a classroom simulator for Python

Students write small Python programs: move the Robot across a field, paint cells, check walls, and solve tasks. Everything runs locally, with the result shown in the desktop window.

Robot desktop window showing a colorful grid task with the robot, walls, and goal.
The Robot window shows the field, walls, task goal, and the result of each run.

Why Robot works well in class

Tasks are small problems on a clear field. Students practice command sequences, loops, conditions, and functions while seeing the result of their code right away.

  • Readable field tasks

    Walls, marked cells, and the goal are visible from the start, so students can focus on the algorithm.

  • Automatic checking

    After a run, Robot checks the result. Students can see whether the solution passed and try again without waiting for manual review.

  • Multiple environments

    Many tasks include several environments. One program has to pass each variant, which encourages a general algorithm instead of memorized moves.

  • Preview environments first

    Students can open each environment before writing code and see which cases their solution must handle.

  • Step-by-step execution

    Programs can run one command at a time in the Robot window. This is useful for debugging and for explaining a solution on a projector.

  • Limits that match the lesson

    Some tasks limit commands or language constructs. The limits point students toward the intended idea, such as a loop, condition, or function.

Robot window with task intro8: reach the house and paint marked cells along the way.
Task intro8: reach the house and paint every marked cell.

Students can see when it passes

When all environments pass, Robot shows that in the window. Students do not have to wait for a manual check.

Robot window with success state: all environments completed for task w45.

Look through environments before coding

The environment selector lets students inspect each field variant before they plan a solution that works everywhere.

Task w49 environment 1: different wall layout on the grid.
Environment 1
Task w49 environment 2: another wall layout requiring a general solution.
Environment 2

Step through the program

Step mode shows what each command does. It is useful for self-checking and for walking through a solution with the class.

Robot window in step mode: program paused after a move command.

Limits are visible in the UI

When a task has limits, Robot shows them next to the task. Students can see which tools they are expected to use.

Robot window showing task for26 with constraint hints in the UI.
Task with limits
Constraint panel listing operator limits and construct limits for the task.
Constraint details

Using Robot in a lesson

After you introduce a topic, students work through tasks at their own pace. Automatic checking removes part of the routine review, so you can focus on students who need help.

One possible lesson flow

  1. Introduce the topic: movement, a loop, a condition, or a function.
  2. Assign a task from the matching track, such as for12 or w25.
  3. Students run task("…") and improve their program until every environment passes.
  4. Use step mode to discuss tricky bugs or walk through a solution together.

Task tracks

Tasks are grouped by topic, so they can fit into an existing course plan.

  • First stepsintro1intro24
  • Functionsfun1fun20
  • for loopfor1for28
  • for + functionsforfun1forfun9
  • while loopw1w51
  • while + functionswfun1wfun12
  • ifif1if14
  • while + ifwif1wif13
  • if / elseifelse1ifelse12
  • Compound conditionscompound1compound11

Robot commands for students

The Python API is intentionally small. Students can start with from robot import * or import only the names they need.

Minimal example

from robot import *

task("intro8")

move_down()
paint()
move_right()
paint()
move_up()
paint()
move_right()
paint()
move_down()

Task or free field

task("name")
Open a task from the bundled set.
field(width=8, height=6)
Open a free field without a task file.

Movement

move_right()
One cell right.
move_left()
One cell left.
move_up()
One cell up.
move_down()
One cell down.

Cell & walls

paint()
Paint the current cell.
is_free_left()is_free_down()
True if no wall in that direction.
is_wall_left()is_wall_down()
True if there is a wall.
is_cell_painted()
True if the cell is painted.
is_cell_not_painted()
True if not painted.

Values & output

pol()
Pollution value in the current cell (integer).
printn(value)
Print an integer in the current cell.

Get started

  1. Download the module archive from GitHub Releases.
  2. Extract it into the student's working folder.
  3. Place the solution file next to the robot package. You can start from sample_solution.py in the archive.
  4. To choose another task, change the string passed to task(). The task names are listed in the tracks above.

Requirements: Python 3 and the standard library. The Robot window uses tkinter, which is included with most desktop Python installations.

Download the module GitHub