Smart Home League
Step-by-step Lesson Booklet — U14 (Primary)
6 LESSONS
Install & run
The Smart Home League folder you received contains two sub-folders: Windows and Mac.
Windows
- Open the Windows folder and double-click
Smart Home League.exe.
- If Windows shows a security prompt the first time, choose More info → Run anyway.
- The game window opens by itself — that is all.
Mac
- Open the Mac folder and double-click
Smart Home League (Mac).command.
- If macOS refuses: right-click the file → Open → Open (needed only once).
- If macOS offers to install its command-line tools (python3), click Install, then double-click again.
Inside the app: the language switches from the ☰ menu; the base code, the helpers and Match mode sit on each league's front page, and the full rulebook opens from the Rules button.
The AI helper in U14 — extra powers
The same AI helper as First Step, with more senses and moves:
- The compass: the "Turn to °" move is an absolute turn — the robot keeps turning until heading reads your number.
- Room number and clean-%: drop the room and clean senses onto one rule: "while I am in room 2 and room 2 is more than 80% clean…".
- Three-move rules: every rule chains up to three moves — "Turn to 270 → Forward → Turn to 180" is exactly the way out of a room.
- The "leave the finished room" button builds that sample rule in one tap; tune each leg's degree to your map.
- As always: ▶ to run, ⬇ to save, yellow numbers editable inside the code.
The robot's sensors at a glance
- Three ultrasonic distance sensors (US) —
front, frontleft (front-left), frontright (front-right), in centimetres.
- The bumper —
bumperfront and bumperback (0 or 1).
- The colour sensor —
color.
- The compass —
heading, 0 to 359 degrees.
- Room number and clean-% —
room and clean1..clean5.
The ultrasonic distance sensors (US): front looks straight ahead, frontleft front-left, frontright front-right — the orange arc is the touch bumper
Before you start
The golden rule: the robot program runs 10 times a second, top to bottom; whatever you put in wheelleft / wheelright holds until the next run. Every lesson is a complete runnable program — run it in the in-app Tutorial or paste it into the match editor.
Lesson 1 — Three distance sensors, no stopping
The U14 house is bigger and time is money: instead of "stop and turn", STEER with the three front sensors. Obstacle left? Curve right. Obstacle right? Curve left. Blocked ahead? Spin on the spot. Wheels that never stop mean tiles painted back to back.
wheelleft = 25
wheelright = 25
if front < 60: # blocked ahead
wheelleft = 18
wheelright = -18
elif frontleft < 50: # obstacle on the left
wheelleft = 25
wheelright = 8
elif frontright < 50: # obstacle on the right
wheelleft = 8
wheelright = 25
You should see: the robot tours the big house without a stop, gliding past the furniture. Beware: a continuous curve around one chair leg can become an ORBIT — lesson 6 has the cure.
Lesson 2 — Rugs pay nothing
The colour sensor sees a rug BEFORE you enter: green is the big rug — half speed and zero points; purple is a small rug — zero points. Reading the floor before you drive onto it is the habit that builds a good route.
wheelleft = 25
wheelright = 25
if timer > 0:
timer -= 1
wheelleft = -25
wheelright = -8 # curved reverse: leave AND turn
elif color == green: # the big rug
timer = 8
elif color == purple: # a small rug
timer = 5
You should see: just before the green rug it peels away with a curved reverse and picks a fresh path. The green timer is deliberately longer (8 vs 5) — green costs more!
Lesson 3 — timer + state: a two-part manoeuvre
Some manoeuvres have two parts: "back up, THEN turn". timer says how long, and state remembers WHICH part we are in: state = 2 reversing, state = 1 turning right. The block above the logic walks the manoeuvre through, step by step, with just those two numbers.
wheelleft = 25
wheelright = 25
if timer > 0:
timer -= 1
if state == 2: # part 1: reverse
wheelleft = -25
wheelright = -25
if timer == 0: # reverse done?
state = 1 # -> part 2: turn
timer = 4
else: # state == 1
wheelleft = 18
wheelright = -18
elif bumper == 1: # I hit something!
state = 2 # reverse first...
timer = 5
You should see: after every bump it first backs up for half a second and THEN turns — two parts, in order, no confusion. Change timer = 4 to tune the turning angle.
Lesson 4 — Three styles for a lasting move
You have three tools. Style 1: timer + the countdown block (you count yourself). Style 2: movetime — set the wheels and say how many steps to hold them; the countdown is automatic. Style 3: easy moves — backward(2) and friends; the number is seconds. The code below runs style 1; the comments show 2 and 3.
wheelleft = 25
wheelright = 25
# STYLE 1: the timer
if timer > 0:
timer -= 1
wheelleft = -25
wheelright = -25
elif color == green:
timer = 20 # 20 steps = 2 seconds
wheelleft = -25
wheelright = -25
# STYLE 2: movetime - delete the block above and try:
# if color == green:
# wheelleft = -25
# wheelright = -25
# movetime = seconds(2)
# STYLE 3: easy moves - the shortest:
# if color == green:
# backward(2)
You should see: All three styles do the same thing: ~2 seconds of reverse when green appears. Run style 1 first, then un-comment 2 and 3 — and watch timer / movetime count down live in the panel.
Lesson 5 — The compass (heading)
What U14 has and FS does not: heading — the robot's direction from 0 to 359 degrees (0 = east, 90 = north, 180 = west, 270 = south). With it you can write "face north", re-find your path after ten manoeuvres, or aim at the rival's half.
wheelleft = 25
wheelright = 25
# face north (90 degrees), then drive straight
if heading < 82 or heading > 98:
wheelleft = -12 # turn until you face north
wheelright = 12
else:
wheelleft = 25 # facing north -> drive
wheelright = 25
if bumper == 1: # hit something?
backward(1) # back off - then find north again
You should see: the robot first spins until heading reads about 90 in the panel, then drives straight north; after every bump it finds north again. Change 90 to 0 to face east.
Lesson 6 — Corners, and the one-side rule
When ALL THREE distance sensors read small numbers you are in a corner — tiny wiggles just put you back; one big turn is needed. And a measured finding from the champion code: escapes that alternate sides make the robot ping-pong between two obstacles. In our test, always-right took 142 tiles and the variable escape only 54!
wheelleft = 25
wheelright = 25
if timer > 0:
timer -= 1
wheelleft = 18 # turn right - ALWAYS right!
wheelright = -18
elif front < 55 and frontleft < 55 and frontright < 55:
timer = 8 # a corner: one big turn (~130 deg)
elif front < 70:
timer = 3 # a wall: a short turn
You should see: straight lines in the open, short turns at walls, and one big ~130-degree turn that frees it from corners. Now open the U14 champion from the robots menu and compare — these very lessons sit side by side in it.