An algorithm is a list of steps you follow in order. Every room of the Night Ferry has one, and they build on each other the same way the week does on the real V5 robot. Find your room, follow its steps, and check the example. Every picture here is a real screen from the game.
Runs your program as many times as the level asks, here five. One run proves nothing; the level wants the whole set.
■ Stop
Stops the runs early.
Logbook
One line per run: where it ended, how far apart the runs landed (the spread), and how many times it reversed.
Heading · Target · Error
On the water: where the ferry points, where you want it, and how far off it is right now.
Brain
Whatever your program prints, the same as the V5 Brain screen.
Python
Open VEXcode V5 under the blocks to see your program as Python. It is the same program, written as text.
Show me the answer
Loads a working program. It costs the "without Show me" star.
Three words the whole week uses
Target: the heading you want, in degrees. 0 is north, 90 is east.
Error: Target − heading. How far off you are, and which way.
Band: how close counts as arrived.
Room 1 · The Timed Run · levels 1-1 and 1-2
Drive and turn on a timer
A program that moves for a set time, run five times, to see how much a timer can be trusted.
Cast off: drive on a timer
The algorithm
drive forward: the motors start and keep going.
wait 2 seconds: the program pauses while the boat moves.
stop driving: the motors cut, and the boat coasts a little.
Press ▶ Run ×5 and read the five stops in the logbook.
Three blocks, top to bottom. Order matters: start, wait, stop.Same program, five different stops. The spread is how far apart they landed: the error a timer cannot see.
A timed turn: tune for the average
The tuning algorithm
Build turn right, wait, stop driving, and Run ×5.
Read the average of the five, not the best one.
Average short of 90? Make the wait a little longer. Past 90? A little shorter.
Change it in small steps and Run again, until the average is within 8° of 90.
Then look at the spread. That is how far a timer turn wanders even when the average is right.
The starting program averages under 50°: not far enough. The game says wait a little longer.
Mistakes to watch for
Expecting the same stop every time. Same program, same boat, five different stops.
Tuning until one run looks perfect. Tune for the average, then look at the spread.
Room 2 · The Compass · levels 2-1 and 2-2
Calibrate, read, and measure
The Inertial sensor gives the heading. It has to calibrate first, and it drifts over time.
Calibrate, and wait for it
The algorithm
calibrate Inertial: the sensor finds its own zero. The boat must be still.
wait until not Inertial calibrating?: do not read anything until it is done.
forever: print the heading on the Brain, then wait 0.5 seconds.
Calibrate, wait for it, then read in a loop.
Measure the drift
The algorithm
Run it. The boat is tied up and still for three minutes, printing every 10 seconds.
Read the Brain at about 0:00, 1:00 and 3:00.
Drift per minute = (reading at 3:00 − reading at 0:00) ÷ 3.
Check it with the 1:00 reading: it should have moved about one minute's worth.
Type your answer, in degrees per minute, into the logbook.
A real run: 0.05 at 0:02 and 3.67 at 3:02. (3.67 − 0.05) ÷ 3 ≈ 1.2° per minute. At 1:02 it read 1.29, about one minute's worth. It checks.
Your numbers will be different
Every player's sensor has its own drift, faster or slower, up or down.
Use your Brain readings, not these.
A drifting heading is why the robot needs to steer by the sensor all the time, not once.
Mistakes to watch for
Reading the heading while it is still calibrating. That number has not been decided yet, and nothing warns you.
Saying "not much". Degrees per minute is a measurement; "not much" is not.
Room 3 · The Hunt · levels 3-1 to 3-3
Steer by the compass
Turning until the heading equals the Target does not work. Steering both ways works, but it hunts.
Make it hunt: why equals fails
The algorithm
Run the program you are given. Do not fix it yet.
Watch the heading as it reaches 90. It goes past.
Why: the heading arrives in steps (88.9, 89.8, 90.6) and skips the one exact number the program waits for.
It waits for heading = Target.It turned all the way round and never stopped: the heading never equalled 90.
Steer both ways
The algorithm
set Target to 90.
forever: if heading < Target then turn right, else turn left.
Run it and count the reversals in the logbook.
Always turning toward the Target.It gets there, then reverses over and over. That is the hunt: it is always turning one way or the other.
Slow it down
The tuning algorithm
Add set turn velocity at the very top.
Lower the % a step at a time and Run.
Read the wobble at the end of the run. Keep going until it is under 8° side to side.
Too slow and it never reaches 90 in time. Go back up a step.
Mistakes to watch for
Trusting equals with a sensor. Use < and >.
Thinking it will settle. With only two choices, right or left, it never stops.
Slowing it down so much it never gets there.
Room 4 · Dead Water · levels 4-1 to 4-4
The deadband: close enough counts
Give the program a third choice: when it is close enough, do nothing. That band is the deadband, like a held bumper.
The deadband algorithm
set Target, set Band, set turn velocity.
forever: set Error to Target − heading.
if abs of Error < Band then stop driving. Close enough, from either side.
else: if Error > 0 then turn right, else turn left.
Run all three. The goal is to stop once, cleanly.
The three choices: stop, turn right, turn left.
All three held inside the band, with one rock each. It passes, and a slightly wider band or a slower turn stops it cleanly.The same program in Python. abs of becomes abs().
Tuning the band (4-2 and 4-4)
Still hunting (lots of reversals)? The boat coasts further than the band is wide: widen the band or turn slower.
Stopping too far from Target? The band is too wide: shrink it.
To find the narrowest band that works: start wide, shrink it a step at a time, and when it starts hunting, go back one step.
A faster turn coasts further, so it needs a wider band (4-4).
Hold the line (4-3)
Inside the band, drive forward instead of stopping.
Outside it, turn back toward the Target.
A turn stops the driving on this drivetrain, so the drive has to come back on inside the band.
4-3 starts you here. Build the choices under set Error.
Mistakes to watch for
A band smaller than the overshoot. If the ferry coasts further than the band is wide, it still hunts.
Leaving out abs of. Arriving from either side has to count.
Thinking a wider band is safer. It is just less accurate.
Room 5 · The Short Way · levels 5-1 to 5-6
Turn the short way across north
Heading is a circle, not a ruler: 359 and 1 are two degrees apart. Plain Target − heading can send the ferry the long way round.
The fold
Replace the Error with: Error = remainder of (Target − heading + 540) / 360, minus 180.
That always gives a number from −180 to 180: the short way, and which side.
The starting program uses plain Target − heading.From 350 to 10 it went the long way round and never arrived in time.
Only the set Error line changes. With the fold, the same trip is 20° to the right.
In Python the remainder is %: ((Target − heading) + 540) % 360 − 180.Fixed: twenty degrees right, the short way, and it stopped once inside the band.
The rest of the room
Any heading (5-2) and the night crossing (5-5): the harbor master sets Target, so take your set Target block out. Every trip has to take the short way and stop, even 270 → 135, which never crosses north.
Ten runs, measured (5-3): run your heading turn ten times against the timer turn from Room 1, and compare the two spreads in the logbook.
As tight as it goes (5-6): band of 2°, 9 of 10 runs inside it. Change only the turn velocity: a tighter band needs a slower turn.
The pilot's touch (bonus, 5-4): inside the loop, set turn velocity to abs of Error × a number. Start the number at 2 and ease it down until the ferry stops without rocking.
Mistakes to watch for
Treating heading like a ruler. It is a circle.
Testing only the turns that cross north. The fold has to get every turn right.
Calling it from one good run. Ten runs is a measurement; one run is an anecdote.
Shrinking the band and keeping the speed. A tighter band needs a slower turn.
The short version
Six rules for the whole harbor
Run it more than onceRead the spread, not one run. The average tunes it; the spread judges it.
Calibrate, then waitNo reading until not calibrating. Drift is degrees per minute.
Never equalsA sensor skips past exact numbers. Use < and >.
Three choicesInside the band: stop. Error positive: right. Negative: left.
Band vs speedHunting? Widen the band or slow the turn. Faster needs wider.
The short wayError = remainder of (Target − heading + 540) / 360 − 180.