October 15, 2026

How to externalize intelligence

The classical understanding of artificial intelligence was that the intelligence is always located inside a robot. Inside the robot there is a microcontroller, on this microcontroller is running a software, the software is based on algorithms and intelligence is located in the algorithm.

With the advent of embodied AI since 1990, this strict philosophy was modified. A more recent understanding is, that intelligence can be located on multiple locations like inside the robot, in the environment of the robot or in both locations. A typical example for externalizing intelligence is a line following robot. The robot does not decide about the path but the decision was given by the line on the ground. The robot follows only the line.

A more advanced version of externalizing intelligence is corridor with qr codes. The robot navigates along the qr codes until he reaches the goal. Its possible to guide the robot to a different goal by changing the position of the qr codes. The software on the robot remains the same.

A teleoperated robot has no internal algorithm at all but its decision making process is determined entirely by the environment. In other words, the intelligence is located outside of the robot. Such sort of machinery is very easy to program, because intelligence offloading means that there is no need to code intelligence in software, but intelligence is already available in the environment.

Intelligence offloading generates a new problem which is how to communicate with a robot. In case of a line following robot, the robot needs a sensor to detect the black line, a robot who follows qr codes needs a camera, and a speech enabled robot will need a microphone plus a language parser. None of these technical artifacts have its root in artificial intelligence but they are standard components used for signal transmission. This makes it easy to build such robots.

Instead of designing advanced algorithms and increasing the onboard intelligence of a robot, the new goal is to invent advanced human to robot communication interfaces which makes it easier to submit commands to the robot. The most advanced interface available is based on natural language. Its more advanced than a light seeking robot because natural language works on a high abstraction level. A short sentence triggers a complex reaction of the robot.

Let me give a practical example for human to robot interaction. 
a) the human operator asks the robot to move to a certain position in a maze
b) the human operator asks the robot to follow a sequence of waypoints in a maze
c) the robot should solve a complex pick& place problem like "transport all the boxes in room A"

These examples are sorted by its difficulty. Programming the language interface for case a) is easy. The robot needs only a list with possible locations in the maze and simple path planning algorithm to reach the goals. In contrast, the cases b) and c) are harder to implement. Parsing and executing the commands is a demanding task for a robot.

Strictly spoken a remote controlled robot doesn't need onboard intelligence but the intelligence is located outside of the robot. There is no algorithm which provides intelligence, but the decision is made by the environment and the robot responds to the decision.

A light seeking robot is a good example for an external controlled robot. The robot follows the light, but do not solves motion planning problems. Such a robot works only if a light source is available in the environment. If the light source is at north, the robot will move towards this direction. According to the strict definition of a robot, such a light seeking automaton is not a robot but its an automaton. It doesn't has a program and its doesn't execute an algorithms. A light seeking robot can be realized with out a microcontroller but as an analog circuit. So its not a computer.

Interaktion von Maschine und Umgebung

Peter Wegner hat in seinen Aufsätzen die Grenzen von Turing Maschinen dargelegt und schlägt als Ergänzung vor, die Interaktion zwischen Turing Maschine und Umgebung zu nutzen. Es geht darum, aus einem Closed system ein open System zu gestalten.

Doch betrachten wir die Thematik von Anfang an. In der Informatik wird zuerst eine Software geschrieben, diese wird auf einem Computer ausgeführt. Auch Robotikprogrammierung funktioniert nach diesem Prinzip. Das Erstellen einer Software für Robotikaufgaben gilt jedoch als anspruchsvoll, einige behaupten sogar es ist nicht durchführbar weil die Realität zu komplex ist um sie in Software abzubilden. Man kann das am praktischen Beispiel sehen wo in den 2000er Jahren die ersten selbstfahrenden Autos programmiert wurden, und die Software einen umfang von 200k Lines of code hatte und das Auto trotzdem nicht im Stande war wie ein Mensch zu fahren.

Bei klassischer Software legt der Fokus der Programmierer auf der Software, deren Programmiersprache, deren interne Datenstruktur und deren interne Algorithmen. Während die Kommunikation der Software mit der Umgebung nur eine geringe Priorität erhält. Das selbstgesteckte Ziel ist häufig einen autonomen Roboter zu programmieren und der soll definitionsgemäß nicht mit der Umwelt interagieren.

Durch diesen Bias hin zu closed systems steigt die Komplexität der Software massiv an. Im Grunde gilt es, die Umgebung in Software nachzubilden, also mittels realistischer physics engine, Trajektoriemodellen bis hin zu Model predictive control. Ein solches System zu entwickeln ist anspruchsvoll und sehr fehleranfällig. An diesem Punkt iind in der vergangenheit zahlreiche projekte gescheitert. Selbst überschaubare Aufgaben wie das navigieren in einem Micromouse Labyrinth ist über ein closed system was Algorithmen folgt sehr schwierig.

Die Antwort liegt nicht in besseren Programiersprachen, oder effienteren Algorithmen wie Rapidly exploring random tree zur Wegplanung sondern die Antwort liegt in den Augen von Stevan Harnad und Peter Wegner in der Kommunikation mit der Umwelt. Damit wird die Künstliche Intelligenz nicht mehr im Roboter implementiert sondern sie wird in der Umwelt verortet und der Roboter greift nur noch darauf zu.

Genauer gesagt besteht die künstliche Intelligenz um einen Roboter zu steuern in menschlichen Bediener der sich außerhalb des Roboters befindet und von dort Kommandos erteilt wie "langsam fahren, anhalten". Durch braucht die Künstliche Intelligenz nicht mehr in Software implementiert werden sondern der Roboter muss lediglich die Steuersignale aus der Umwelt auswerten.

Auf den ersten Blilck klingt dieser ansatz wie eine Sackgasse. Dort wo ein menschlicher Bediener  benötigt wird, agiert der Roboter nicht mehr autonom und folglich ist seine Effizienz gering. Dies ist aber nur bei Low level fernsteurung der Fall, wo also über einen Joystick die Steuerstgnale erzeugt werden. Bei einer high level Fernsteuerung über natürliche Sprache steigt die Effizienz. 

Eine high level Fernsteuerung über Textkommandos hat Ähnlichkeit mit einem Textadventure. Dort erzeugt das Computerprogram eine Umgegungsbeschreibung und der menschliche Spieler gibt ein Kommando ein wie "öffne Kiste". Derartige Textadventure lassen sich erstaunlich simpel mittels Algorithmen automatisch durchspielen weil ihr Zustndsraum klein ist. Es gibt nur eine geringe Anzahl von Befehlen, die zu einer überschaubaren Anzahl neuer Spielzustände führen. Fogllich kann man die Nutzereingaben und die Reaktion der Game engine gut als vollständigen Game tree traversieren, also so wie auch ein Schachcomputer funktioniert.

Doch zurück zur Interaktion einer Maschine mit der Umgebung. Anders als ein Algorithmus der intern von einer Maschine ausgeführt wird, erfolgt die Interaktion der Maschine mit ihrer Umwelt als Kommunikativer Prozess vergleich mit einem TCP/IP Request im Internet. Eine solche Kommunikation kann man über ein mehrschicht protokoll formalisieren. Speziell zur Interaktion von Robotern mit deren Umwelt eignet sich eine dialog Grammatik für diese Aufgabe. Eine Dialoggrammatik ist eine BNF Grammar welche mögliche Verben, Substantive und Adjektive enthält. Darin wird spezifiziert dass der Robotter folgende aktionen ausführen kann:
- move, stop, rotate, grasp, ungrasp

Und dass der Roboter folgende Orte kennt:
- roomA, roomB, Door, chargingstation

Eine solche BNF Grammar ist also eine symbolische Abstraktion der Wirklichkeit beschrieben in natürlicher Sprache. Über diese Abstraktion kommuniziert der Roboter mit der Umwelt. Der Roboter kann z.B. seinen Status mitteilen "my location is RoomA". und er kann Befehle ausführen wie "move to RoomB".

October 14, 2026

Frühe ferngesteuerte Automaten

 Es gibt eine Reihe von Zaubertricks und technischen Vorführungen vor Beginn des Computerzeitalters die auf das damalige Publikum erstaunlich gewirkt haben. Streng genommen waren diese Maschinen keinen Roboter, weil sie keine Microcontroller enthielten, also eine CPU. Dennoch zeigten sie ein Verhalten was roboterähnlich aussah. Hier die Zeitleiste:

1770    Schachtürke von Wolfgang von Kempelen
1849    Antonio Diavolo von Robert-Houdin
1904  Telekino von Leonardo Torres Quevedo
1939    Elektro auf der New Yorker Weltausstellung

Die Funktionsweise dieser Darbietungen basierte auf mechanischer oder elektromechanischer Fernsteuerung. Vom Schachtürken ist bekannt dass ein erfahrener Menschlicher Schachspieler in der Kiste saß, von der Trapez-Marionette Antonio Diavolo ist bekannt dass sie über Baudenzüge gesteuert wurde, die in der Halterung versteckt waren, während das Telekino Boot von Quevedo mittels Funksignale aus der Distanz gesteuert wurde.

Die Erfinder hatten folglich die Aufgabe, diese Fernsteuerung zu realisieren. Entweder über mechanische angelsehnen wie es bei vielen Zaubertricks üblich ist, oder über das Übertragen von Funksignalen was seit 1895 möglich ist.

All die aufgeführten Automaten waren nicht autonom, sondern es gab einen menschlichen Bediener der heimlich Knöpfe gedrückt hat wodurch der Automat sich bewegt hat und das Publikum zum Staunen animiert hat.

Mit Aufkommen der ersten Computer ab den 1950er schien diese Technik des ferngesteuerten Automaten in Vergessenheit geraten zu sein. Stattdessen versuchten Robotik-Ingineure ein Programm zu schreiben was auf dem Computer ausgeführt wird, und darüber den Roboter zu steuern. Dies wurde speziell in der universitären Robotik als Goldstandard definiert. Gleichzeitig wurden ferngesteuerte Roboter oder mechanisch ferngesteuerte Automaten als unwissenschaftliche Zauberillusion belächelt.

Die Abkehr von ferngesteuerten Bühnentricks hinzu programmierten Robotern führte in eine Sackgasse welche zuerst nicht wahrgenommen wurde. Die Sackgassen entsteht dadurch dass ein computerprogram niemals so leistungsfähig sein kann wie ein menschlicher Bediener. Gleichzeitig sind ferngesteuerte Automaten einfacher zu konstruieren. Technisch gesehen sind es lediglich empfangseinrichtungen welche Befehle aus der Ferne in Bewegung umsetzen.

BNF Grammar for speaker to hearer interaction for a warehouse robot

A bnf grammar is a good starting point to specify a language game. The grammar provides possible action verbs, nouns and adjectives. Possible requests send to the robot are formulated in the syntax of the grammar.

For the example of a warehouse robot, possible utterances are:

Visual Question Answering (VQA)

Interaction 1: Count Query
    Speaker (Human): "How many boxs are on Conveyor 1?"
    Hearer (Robot): "Answer: 4."

Interaction 2: Attribute Query
    Speaker (Human): "What color is the parcel at Rack A Level 2?"
    Hearer (Robot): "Answer: blue."

Interaction 3: Location Query
    Speaker (Human): "Where is the container?"
    Hearer (Robot): "Answer: Pallet 3."

Interaction 4: Presence Query
    Speaker (Human): "Is there a item inside Bin 5?"
    Hearer (Robot): "Answer: Yes."

Instruction Following (IF)

Interaction 5: Pick & Place Action
    Speaker (Human): "Pick up the red parcel from Conveyor 2"
    Hearer (Robot): "Executing: Picked up red parcel."

Interaction 6: Movement Action
    Speaker (Human): "Move the damaged box to Bin 8"
    Hearer (Robot): "Task completed: Moved damaged box."

Interaction 7: Inspection Action
    Speaker (Human): "Inspect the barcode at Rack B Level 1"
    Hearer (Robot): "Task completed: Inspected barcode."

Interaction 8: Placement Action with Error
    Speaker (Human): "Place the blue container to Pallet 9"
    Hearer (Robot): "Error: Path obstructed."

These speech acts were not created by a large language model, but are possible vectors from a BNF Grammar, given next. A bnf grammar is a vocabulary list plus grammar rule system and defines what each side can say.

BNF Grammar    

<interaction>         ::= <speaker_turn> " -> " <hearer_turn>

<speaker_turn>        ::= <command> | <query>
<hearer_turn>         ::= <acknowledgment> | <answer> | <error_response>

;; Command & Query Structure
<command>             ::= <action_verb> " " <target_object> <location_clause>
<query>               ::= <vqa_question>

<vqa_question>        ::= <count_query> | <attribute_query> | <location_query> | <presence_query>

<count_query>         ::= "How many " <object_type> "s are on " <surface> "?"
<attribute_query>     ::= "What color is the " <object_type> " at " <location_spec> "?"
<location_query>      ::= "Where is the " <object_type> "?"
<presence_query>      ::= "Is there a " <object_type> " inside " <container> "?"

<action_verb>         ::= "Pick up the" | "Move the" | "Inspect the" | "Place the" | "Scan the"
<target_object>       ::= <color> " " <object_type> | <object_type>
<location_clause>     ::= " from " <location_spec> | " to " <location_spec> | ""

<location_spec>       ::= <surface> | <container> | <shelf_location>
<surface>             ::= "Conveyor " <digit> | "Pallet " <digit>
<container>           ::= "Bin " <digit> | "Crate " <alpha_code>
<shelf_location>      ::= "Rack " <alpha_code> " Level " <digit>

;; Robot Responses
<acknowledgment>      ::= "Executing: " <action_description> "." | "Task completed: " <action_description> "."
<action_description>  ::= <action_verb_past> " " <target_object>
<action_verb_past>    ::= "Picked up" | "Moved" | "Inspected" | "Placed" | "Scanned"

<answer>              ::= "Answer: " <answer_content> "."
<answer_content>      ::= <digit_string> | <color> | <location_spec> | <boolean>

<error_response>      ::= "Error: Object not found." | "Error: Path obstructed."

;; Lexical Elements
<object_type>         ::= "box" | "parcel" | "barcode" | "container" | "item"
<color>               ::= "red" | "blue" | "green" | "yellow" | "damaged"
<boolean>             ::= "Yes" | "No"
<digit_string>        ::= <digit> | <digit> <digit_string>
<digit>               ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
<alpha_code>          ::= "A" | "B" | "C" | "D"

Einführung in grounded language

 Das Ziel besteht darin natürliche Sprache also Englisch oder Deutsch zu verwenden um damit Robotikaufgaben zu lösen. Konkret sind damit Aufgaben wie motion planning, greifplanung und die navigation auf Straßen gemeint. Der Ansatz zur Lösung natürliche Sprache zu verwenden klingt zunächst ungewohnt weil üblicherweise Probleme der Informatik über das schreiben von Computer code sowie über mathematische Algorithmen gelöst werden. Natürliche Sprache ist demgegenüber schwer formalisierbar und für Computer gänzlich unverständlich da Computer nur Assembly befehle abarbeiten können.

Der Umweg über den grounded language machinenlesbar wird sind Computerspiele die etwas mit Vokabellernen zu tun haben. Der erste Schritt besteht darin einige solche Vokabelspiele als Programm zu realisieren:

- Bilder zu Worten zuordnen
- Deutsche Worte in Englische Worte übersetzen
- auf ein Objekt zeigen
- eine kurze Anweisung mit einem Roboter ausführen

All diese Spiele sind Wortspiele bzw. vokabelspiele. Es gibt diese Beispiele bereits als fertige Software man kann sie aber auch from scratch neu programmieren was empfohlen wird, weil sich dann leichter Erweiterungen hinzufügen lassen. Anders bei einem klassischen Vokabellernspiel geht es weniger darum, dass der menschliche Anwender die Vokabeln auswendig lernt sondern Ziel ist dass ein Computer sowohl die Fragen formuliert, als auch Antworten gibt. Die dabei verwendeten Algorithmen und Datenstrukturen sind im Bereich grounded language angesidelt. z.b. kann ein Bild zu Wort spiel mit Hilfe einer Lookup Tabelle durch einen Computer gelöst werden, während das pointing game über ein python dictionary lösbar ist.

Der Fokus auf Sprachspiele ist deshalb erforderlich weil sich in einem Spiel ein Thema maschinell formalisieren lässt. Es geht darum in einem regelsystem eine Entscheidung zu treffen, also z.B. für das Wort "Apfel" das objekt in einem Bild zu finden was wie ein Apfel aussieht.

Aus Sicht der Informatik sind Vokabellernspiele die Antwort auf die Zustandsraumexplosion. Speziell Robotikaufgaben besitzen einen sehr großen Zustandsraum der von gängigen Suchalgorithmen nicht in Echtzeit untersucht werden kann. Indem eine Aufgabe wie greifpalnung als Sprachspiel gedeutet wird, verkleinert sich der zustandsraum. Sprache ist demzufolge eine Universalheuristik mit der frühere unlösbare KI Probleme plötzlich lösbar werden.

October 11, 2026

Interactive turing machines

Classical turing machines are based on algorithms. The algorithm is stored in program and gets executed by the CPU. This model is powerful because it describes all sort of software from games to databases and word processing software.

There were many attempts available mostly driven by theoretical curiosity to extend classical Turing paradigm into Super turing machines (by HT Siegelmann), oracle turing machines and interactive turing machines [1]. Each author defines the principle a bit different so here is an introduction into the subject.

Instead of running an algorithm, there is a speaker to hearer language game. That means, a robot communicates with the outside world. The robot is the hearer and the outside world is the speaker. The robot behaviors doesn't depends on its internal algorithm but the robot gets teleoperated. The importance of the robot's internal software is reduced to a minimum, technically spoken the robot is only the receiver in a remote control setup and the decision are made by the speaker.

Such sort of interactive Turing machine is more powerful than a normal turing machine because it allows to solve tasks from artificial intelligence like navigating in a room, grasping objects and so on. Instead of designing better algorithms, e.g. for motion planning, the focus in on the communication interface between the speaker and the hearer. This interface is described by a dialogue grammar, similar to a protocol grammar. The grammar defines which sentences are valid.

[1] Wegner, Peter. "Why interaction is more powerful than algorithms." Communications of the ACM 40.5 (1997): 80-91.


October 09, 2026

Event recogntion grammar for maze robot

 _

BNF grammars are known for programming language specification but are also useful for language games between speaker and hearer. A pointing game or an instruction following game can be realized with such a grammar. Reversing a pointing game results into an action recognition game in which a human controls a robot with arrow keys, and the grammar recognizes the demonstrated actions. Such an action recognition game was implemented in python as a simple maze game. The robot can move around and pick&place objects. 
The game doesn't need a large language model and not a vision language action model realized as a neural network, but its a symbolic approach based on a grammar.[1][2]

[1] Dantam, Neil, Irfan Essa, and Mike Stilman. "Linguistic transfer of human assembly tasks to robots." 2012 IEEE/RSJ International Conference on Intelligent Robots and Systems. IEEE, 2012.
[2] Wegner, Peter, and Dina Goldin. "Computation beyond Turing machines." Communications of the ACM 46.4 (2003): 100-102.
 

import re
import pygame


# -------------------- Configuration --------------------

COLS, ROWS = 20, 14
CELL = 36
GRID_W, GRID_H = COLS * CELL, ROWS * CELL
LOG_H = 180
WIDTH, HEIGHT = GRID_W, GRID_H + LOG_H

# '#' is a wall; '.' is a walkable cell.
MAZE = [
    "####################",
    "#....#.............#",
    "#....#..####..###..#",
    "#.......#.....#....#",
    "###.##..#..##.#.##..#",
    "#...##.....##......#",
    "#.######.####.###..#",
    "#........#.........#",
    "#.###.####.###.##..#",
    "#.....#......#.....#",
    "###.#.#.####.#.###..#",
    "#...#..........#...#",
    "#........#.........#",
    "####################",
]

# Named locations are recognized in the event log.
LOCATIONS = {
    "start": (1, 1),
    "junction": (7, 3),
    "workshop": (15, 5),
    "storage": (4, 9),
    "exit": (18, 12),
}

# Objects can be picked up and placed with G.
OBJECTS = {
    "red_key": (3, 3),
    "blue_box": (16, 9),
    "coin": (9, 11),
}

# Robot begins at the named "start" location.
robot = list(LOCATIONS["start"])
carried_object = None
event_log = ["Arrow keys: move    G: pick up / place"]

# Draw colors
WHITE = (255, 255, 255)
BLACK = (25, 25, 25)
WALL_COLOR = (70, 75, 85)
GRID_COLOR = (205, 205, 205)
ROBOT_COLOR = (30, 105, 220)
LOCATION_COLOR = (30, 135, 65)
OBJECT_COLORS = {
    "red_key": (205, 45, 45),
    "blue_box": (45, 80, 205),
    "coin": (190, 145, 0),
}


# -------------------- Event grammar --------------------

# Events emitted by the controls:
#
# <event>       ::= <move-event> | <grasp-event> | <ungrasp-event>
# <move-event>  ::= "movto" <location>
# <grasp-event> ::= "grasp" <object>
# <ungrasp-event> ::= "ungrasp" <object>
#
# <location> includes the named locations above and all walkable maze cells,
# represented as cell_X_Y. <object> includes the names in OBJECTS.
#
# The parser below checks both the event's form and its vocabulary.

def location_names():
    names = set(LOCATIONS)
    for y in range(ROWS):
        for x in range(COLS):
            if MAZE[y][x] != "#":
                names.add(f"cell_{x}_{y}")
    return names


LOCATION_NAMES = location_names()
OBJECT_NAMES = set(OBJECTS)

EVENT_PATTERNS = [
    ("movto", re.compile(r"^movto\s+([a-z][a-z0-9_]*)$")),
    ("grasp", re.compile(r"^grasp\s+([a-z][a-z0-9_]*)$")),
    ("ungrasp", re.compile(r"^ungrasp\s+([a-z][a-z0-9_]*)$")),
]


def parse_event(text):
    """Return (verb, argument) if a generated event matches the grammar."""
    for verb, pattern in EVENT_PATTERNS:
        match = pattern.fullmatch(text)
        if not match:
            continue

        argument = match.group(1)
        valid_names = LOCATION_NAMES if verb == "movto" else OBJECT_NAMES
        if argument in valid_names:
            return verb, argument

    return None


def log_recognized_event(text):
    """Only add events that are accepted by the grammar."""
    if parse_event(text) is not None:
        event_log.append(f"Recognized: {text}")
        del event_log[:-7]


def location_at(x, y):
    """Prefer a named location; otherwise use the cell's generated name."""
    for name, position in LOCATIONS.items():
        if position == (x, y):
            return name
    return f"cell_{x}_{y}"


# -------------------- Robot actions --------------------

def is_walkable(x, y):
    return (
        0 <= x < COLS
        and 0 <= y < ROWS
        and MAZE[y][x] != "#"
    )


def move_robot(dx, dy):
    x, y = robot
    nx, ny = x + dx, y + dy

    if not is_walkable(nx, ny):
        return

    robot[:] = [nx, ny]
    log_recognized_event(f"movto {location_at(nx, ny)}")


def toggle_grasp():
    global carried_object

    current_cell = tuple(robot)

    if carried_object is not None:
        # Place the held object on the robot's current cell.
        if current_cell in OBJECTS.values():
            event_log.append("Cannot place: this cell already has an object.")
            del event_log[:-7]
            return

        object_name = carried_object
        OBJECTS[object_name] = current_cell
        carried_object = None
        log_recognized_event(f"ungrasp {object_name}")
        return

    # Pick up an object on the robot's current cell.
    for object_name, position in OBJECTS.items():
        if position == current_cell:
            carried_object = object_name
            del OBJECTS[object_name]
            log_recognized_event(f"grasp {object_name}")
            return

    event_log.append("No object here to pick up.")
    del event_log[:-7]


# -------------------- Pygame setup and drawing --------------------

pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Robot Maze — BNF Event Log")
clock = pygame.time.Clock()

font = pygame.font.Font(None, 24)
small_font = pygame.font.Font(None, 19)
robot_font = pygame.font.Font(None, 28)


def draw():
    screen.fill(WHITE)

    # Maze
    for y in range(ROWS):
        for x in range(COLS):
            rect = pygame.Rect(x * CELL, y * CELL, CELL, CELL)
            if MAZE[y][x] == "#":
                pygame.draw.rect(screen, WALL_COLOR, rect)
            pygame.draw.rect(screen, GRID_COLOR, rect, 1)

    # Named locations
    for name, (x, y) in LOCATIONS.items():
        label = small_font.render(name, True, LOCATION_COLOR)
        screen.blit(label, (x * CELL + 3, y * CELL + 2))

    # Objects
    for name, (x, y) in OBJECTS.items():
        cx = x * CELL + CELL // 2
        cy = y * CELL + CELL // 2 + 4
        pygame.draw.circle(screen, OBJECT_COLORS[name], (cx, cy), 10)
        label = small_font.render(name, True, BLACK)
        screen.blit(label, (x * CELL + 2, y * CELL + CELL - 17))

    # Robot, displayed as R
    rx, ry = robot
    robot_label = robot_font.render("R", True, ROBOT_COLOR)
    robot_rect = robot_label.get_rect(
        center=(rx * CELL + CELL // 2, ry * CELL + CELL // 2)
    )
    screen.blit(robot_label, robot_rect)

    # White event log panel
    log_top = GRID_H
    pygame.draw.rect(screen, WHITE, (0, log_top, WIDTH, LOG_H))
    pygame.draw.line(screen, BLACK, (0, log_top), (WIDTH, log_top), 2)

    title = font.render("Recognized events", True, BLACK)
    screen.blit(title, (10, log_top + 8))

    if carried_object:
        held_text = small_font.render(f"Holding: {carried_object}", True, BLACK)
        screen.blit(held_text, (WIDTH - 150, log_top + 11))

    visible_events = event_log[-6:]
    for i, message in enumerate(visible_events):
        text = small_font.render(message, True, BLACK)
        screen.blit(text, (10, log_top + 38 + i * 21))

    pygame.display.flip()


# -------------------- Main loop --------------------

running = True

while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                running = False
            elif event.key == pygame.K_UP:
                move_robot(0, -1)
            elif event.key == pygame.K_DOWN:
                move_robot(0, 1)
            elif event.key == pygame.K_LEFT:
                move_robot(-1, 0)
            elif event.key == pygame.K_RIGHT:
                move_robot(1, 0)
            elif event.key == pygame.K_g:
                toggle_grasp()

    draw()
    clock.tick(30)

pygame.quit()
 

October 08, 2026

BNF grammar for instruction following of a kitchen robot

The communication between speaker and hearer can be formalized with a dialogue grammar which contains of objects and actions. The grammar stores a language in a compact format. Possible sentences are:

  1. Put the clean plate on the table.
  2. Place the large bowl beside the sink.
  3. Move the blue cup to the counter.
  4. Cut the small red tomato.
  5. Wash the dirty pan.
  6. Open the cabinet.
  7. Take the bottle from the refrigerator.
  8. Put the whole apple into the bowl.
  9. Clean the empty sink.
  10. Please place the warm bread on the table.
  11. ----
  12. Peel the small yellow potato.
  13. Place the clean glass on the counter.
  14. Move the large pan to the stove.
  15. Put the red pepper into the bowl.
  16. Wash the dirty spoon in the sink.
  17. Take the cold bottle from the refrigerator.
  18. Chop the whole onion on the worktop.
  19. Open the white cabinet.
  20. Fill the empty cup with water.
  21. Please serve the warm bread on the table.
  22. ----
  23. Slice the green tomato.
  24. Put the round plate onto the table.
  25. Clean the large sink.
  26. Bring the blue cup to the counter.
  27. Place the sharp knife beside the cutting board.
  28. Mix the ingredients in the bowl.
  29. Close the open cabinet.
  30. Empty the full container into the pan.
  31. Dry the clean glass near the sink.
  32. Heat the cold soup on the stove.


All these sentences doesn't require the full English vocabulary and the standard grammar for English but the sentences are formulated as a mini language specified in the BNF grammar. Such a mini language can be implemented easier as a parser for robot.

<instruction> ::= <command>
                 | <sequence>
                 | <conditional-command>

<command> ::= <imperative>
            | <polite-imperative>

<polite-imperative> ::= "please" <imperative>

<imperative> ::= <transitive-command>
                | <intransitive-command>
                | <movement-command>
                | <placement-command>
                | <cleaning-command>

<transitive-command> ::= <transitive-verb> <object-phrase>

<intransitive-command> ::= <intransitive-verb>
                          | <intransitive-verb> <location-phrase>

<movement-command> ::= <movement-verb> <location-phrase>
                     | <movement-verb> <object-phrase> <location-phrase>

<placement-command> ::= <placement-verb> <object-phrase>
                      | <placement-verb> <object-phrase> <location-phrase>

<cleaning-command> ::= <cleaning-verb> <object-phrase>
                     | <cleaning-verb> <location-phrase>

<sequence> ::= <command> "and then" <command>
             | <command> "," <command>
             | <command> "then" <command>

<conditional-command> ::= "if" <condition> "then" <command>

<condition> ::= <object-existence>
              | <state-condition>

<object-existence> ::= "there is" <object-phrase>
                      | "there are" <object-phrase>

<state-condition> ::= <object-phrase> <state-adjective>
                    | <location-phrase> <state-adjective>


<object-phrase> ::= <determiner> <adjective-sequence> <object-noun>
                   | <determiner> <object-noun>
                   | <possessive> <adjective-sequence> <object-noun>
                   | <possessive> <object-noun>

<location-phrase> ::= <preposition> <determiner> <adjective-sequence> <location-noun>
                    | <preposition> <determiner> <location-noun>
                    | <preposition> <location-noun>

<adjective-sequence> ::= <adjective>
                       | <adjective> <adjective-sequence>


<transitive-verb> ::= "wash"
                    | "cut"
                    | "chop"
                    | "slice"
                    | "peel"
                    | "mix"
                    | "stir"
                    | "pour"
                    | "fill"
                    | "empty"
                    | "open"
                    | "close"
                    | "pick up"
                    | "put down"
                    | "take"
                    | "bring"
                    | "place"
                    | "move"
                    | "put"
                    | "heat"
                    | "cool"
                    | "serve"

<intransitive-verb> ::= "wait"
                      | "stop"
                      | "start"
                      | "continue"
                      | "turn"
                      | "pause"

<movement-verb> ::= "go to"
                  | "move to"
                  | "take"
                  | "bring"
                  | "carry"

<placement-verb> ::= "place"
                   | "put"
                   | "set"
                   | "leave"

<cleaning-verb> ::= "clean"
                   | "wash"
                   | "dry"
                   | "wipe"


<object-noun> ::= "apple"
                 | "banana"
                 | "tomato"
                 | "potato"
                 | "onion"
                 | "carrot"
                 | "pepper"
                 | "bread"
                 | "cheese"
                 | "egg"
                 | "plate"
                 | "bowl"
                 | "cup"
                 | "glass"
                 | "pan"
                 | "pot"
                 | "knife"
                 | "spoon"
                 | "fork"
                 | "bottle"
                 | "container"
                 | "ingredient"
                 | "food"

<location-noun> ::= "kitchen"
                  | "counter"
                  | "table"
                  | "sink"
                  | "stove"
                  | "oven"
                  | "refrigerator"
                  | "drawer"
                  | "cabinet"
                  | "shelf"
                  | "dishwasher"
                  | "cupboard"
                  | "floor"
                  | "worktop"

<adjective> ::= <color-adjective>
              | <size-adjective>
              | <state-adjective>
              | <shape-adjective>
              | <temperature-adjective>
              | <quantity-adjective>

<color-adjective> ::= "red"
                    | "green"
                    | "yellow"
                    | "blue"
                    | "white"
                    | "black"

<size-adjective> ::= "small"
                    | "large"
                    | "big"
                    | "tiny"
                    | "deep"
                    | "shallow"

<state-adjective> ::= "clean"
                    | "dirty"
                    | "empty"
                    | "full"
                    | "open"
                    | "closed"
                    | "hot"
                    | "cold"
                    | "ready"
                    | "broken"

<shape-adjective> ::= "round"
                    | "square"
                    | "flat"
                    | "sharp"

<temperature-adjective> ::= "warm"
                          | "cool"
                          | "hot"
                          | "cold"

<quantity-adjective> ::= "single"
                       | "extra"
                       | "remaining"
                       | "whole"
                       | "half"

<determiner> ::= "the"
               | "a"
               | "an"
               | "this"
               | "that"
               | "these"
               | "those"

<possessive> ::= "my"
               | "your"
               | "the robot's"

<preposition> ::= "to"
                | "from"
                | "on"
                | "in"
                | "into"
                | "onto"
                | "under"
                | "beside"
                | "near"
                | "behind"
                | "inside"
                | "out of"