The maze robot: what it is and what it must do
A maze robot (a labyrinth robot) is an autonomous robot that finds its own way through an unknown labyrinth from the start to the exit, with no remote control. The labyrinth has been a task at the Georgian Robotics Association's (GRA) school competitions since our first one in 2022 and was one of the two tasks of the 2026 school robotics championship (GRA 2022–2026, the 2026 school competition).
It must do three things: see the walls (distance sensors), decide where to go (a maze algorithm) and move precisely (straight lines, exact 90° turns). This guide covers all three, plus GRA's rules and practice. New to robotics? Start with my first robot and Arduino for beginners.
The school competition: the labyrinth rules (GRA, 2026)
In GRA's 2026 school competition rules the labyrinth is Category II (for 4WD/2WD robots):
- corridors 30 cm wide; the robot finds its own way from the start to the exit;
- 3 minutes at most — a robot that takes longer automatically loses;
- the shortest time wins, from the start line to the finish line; a jury scores the teams;
- 2 attempts, the better one counts;
- a start button — the robot must move within 5 seconds of the press;
- up to 1 kg, fitting in a 180 × 280 mm box;
- one team member comes out to the arena with the robot;
- no remote control; no shockers, jammers or anything that damages the stage;
- the competition labyrinth differs from the rules' picture, so the robot must solve any labyrinth.
In 2026 one robot had to complete both the zigzag and the labyrinth (the report; the zigzag — in the line follower rules). Rules change: each competition publishes its current rules on its own page — competitions.
What this means. To turn round in a dead end, the robot sweeps a circle as wide as its diagonal (axle in the middle). A 180 × 280 mm robot (333 mm diagonal) cannot do it in a 30 cm corridor; a compact 150 × 180 mm one (≈ 234 mm) keeps about 3 cm on each side.
Maze robot sensors and where to put them
The robot "sees" walls with distance sensors:
- Ultrasonic sensor (HC-SR04 type) — times an echo: distance (cm) ≈ time (μs) / 58. Cheap, but a wide cone, slow (tens of milliseconds), and a smooth wall at an angle bounces the echo away. Fire several sensors one after another.
- IR distance sensor (Sharp GP2Y0A type) — fast, analogue, not linear, with a minimum distance (closer reads as far): mount it a few centimetres in from the edge.
- ToF laser sensor (time-of-flight, VL53L0X / VL53L1X type) — a narrow beam, precise and fast readings, I2C; give each a new address at start-up through its XSHUT pin.
Placement (the diagram's numbers): 1 — front: the wall ahead; 2 — left (dL); 3 — two right sensors, front and rear (dR): equal readings mean the robot is parallel to the wall; 4 — diagonal sensors at 45° spot side openings early — here the right beam goes into one; 5 — the 30 cm corridor; 6 — the turning circle, with room to spare.
To stay centred, steer so that e = dL − dR stays near zero. Take the median of three readings to ignore random spikes.
Wall following: the right-hand (or left-hand) rule
The simplest maze algorithm: keep your right hand on the wall. If the start and the exit are both on the outer wall, you will get out — though not always by the shortest way. At every junction the robot checks, in this order:
- right is open → turn right;
- if not, ahead is open → go straight;
- if not, left is open → turn left;
- if not (a dead end) → turn around.
The left-hand rule is its mirror image. In the diagram: 1 — start; 2 — exit; 3 — a dead end; 4 — the order of the checks. The red route hugs the right-hand wall.
Follow the wall continuously — hold a set distance from it (say 7 cm; e = 7 − dR) with PD control, as a line follower does — or cell by cell: drive one 30 cm cell, stop, check, decide. Slower, but best for a first robot.
Where it fails: when the exit is in the middle, or when the robot circles an "island" (walls not joined to the outer wall) until the 3 minutes run out. Then you need memory (next section).
A tip: fit a small switch to pick the right or left hand before the start. If the first attempt is slow, try the other hand — the better result counts.
Maze algorithms: Trémaux and flood fill
An algorithm with memory treats the labyrinth as a grid of cells (30 cm corridors suggest 30 cm cells, though the rules promise no grid) and stores each cell's walls.
Trémaux's algorithm — a 19th-century method that gets you out of any labyrinth, loops included. It marks the passages it uses, in memory:
- at a junction it takes an unmarked passage, or else one marked once;
- if a new passage leads it to a junction it has already seen, it turns back;
- it never enters a passage marked twice.
Flood fill — the classic of micromouse, a competition where a small robot races to the centre of a 16 × 16-cell maze. Each cell holds its distance to the goal: 0 at the goal, 1 next to it, then 2 — like water spreading out. Unknown walls count as absent. The robot always steps to the open neighbour with a lower number and recomputes the numbers whenever it finds a wall. At the goal it has a map for a fast run along the shortest route.
In the diagram: left — what the robot assumes at the start; right — after finding walls. 1 — the goal (0); 2 — the robot; 3 — walls found: the numbers now flow to the goal's only entrance; 4 — the route down ever lower numbers.
Flood fill needs a known goal; for a school labyrinth a good wall follower is often enough.
Moving precisely: encoders, a gyro and staying centred
Small errors add up: be 5° off at every turn, and after ten turns the robot scrapes a wall.
- An encoder counts the wheel's rotation: distance per pulse = π·D / N (D — wheel diameter, N — pulses per turn). A 90° turn in place moves each wheel π·W / 4 (W — the distance between the wheels). With W = 12 cm, D = 6.5 cm and a 20-slot disc that is only ≈ 9 pulses — about 10° each, far too coarse; a magnetic encoder on the motor shaft gives hundreds of pulses per wheel turn.
- A gyroscope (an IMU such as the MPU-6050) measures the rate of turn; add it up over time for the heading and turn until it has changed by 90°. Gyros drift: before the start, standing still, average a few hundred readings and subtract that offset.
Turn by the gyro, count cells by the encoders, drive straight by the walls. Stop before a turn and change speed gently so that the wheels do not slip.
Practice: a training labyrinth and tests
Build a training labyrinth with 30 cm corridors from plywood, MDF or thick cardboard panels you can rearrange — the competition labyrinth will be new to you. The photo at the top shows the plywood labyrinth at our Robo Festival 2024. The rules do not give the wall height, so mount the sensors low.
Test in this order:
- A straight corridor — 2 m centred, no touching;
- Ten turns in a row — the heading does not drift;
- A dead end — a clean turn-around;
- Full labyrinths with a stopwatch — well under 3 minutes, a new layout each time;
- A labyrinth with an "island";
- The button start (moving within 5 seconds) and both hand modes.
Try different lighting (sunlight confuses IR) and log every run. Practise starting the robot single-handed (one member at the arena) and check the weight and size early. Safety: the soldering iron in its stand, a ventilated room, LiPo batteries on a balance charger and never unattended (more).
What next
- The basics — my first robot, electronics basics and Arduino for beginners; PD control — in building a line follower.
- For schools — a robotics club at school, school robotics: line, zigzag, labyrinth and the 2026 school competition.
- The terms — the robotics glossary.
- Current rules and registration — competitions; upcoming events; as a volunteer or partner — get involved.
- Every post on this topic — labyrinth.




