- Learn
- Tutorials
- Algorithms
- Binary Search
- 5 Run and Compare
5 Run and Compare
By the end of this chapter, the computer takes its turns while you watch. You can pause it, compare its search with yours on the same safe, and open a lesson over the game.
The game as it is at the end of this chapter. Click the game to play.
The finished project is here if you’d like to compare your work. It holds every part of Crack the Safe.
To open it, start Myth Engine, choose File › Open Project... and pick the downloaded file.
5.1 The Idea
The room is still, and the computer waits for your finger. Every STEP takes another guess. The gold mark moves, a scan card appears, and the teal band shrinks. The rule you’ve built already chooses the middle and reads the clue. Now let it keep going.
Try the game above. Choose Computer cracks it, lock 100, and press RUN. After a short wait, the first card shows 50, followed by another guess from the smaller range. The cards keep arriving. The safe opens on the seventh scan, and PAUSE disappears.
That pause between guesses gives you time to see which marks the clue removed. Watch the teal band. The computer uses exactly the rule you built in Chapter 4. A Recurring Timer calls for another turn after each interval, like a bell that rings at regular times.
RUN starts that bell, and PAUSE stops it. The range stays where it was. Press STEP while it runs, and the bell stops before your one turn happens. Nothing races your finger.
Then try a safe yourself. Once your attempt ends, Watch computer appears below the safe. Press it. The code stays, your result waits beside the safe, and the computer starts a fresh search. You can compare both attempts because neither got a different code.
A panel covers the room at the end. Myth lesson gathers the Functions you’ve built, with their Parameters and answers. While you read, the game holds still. An Input Context is a group of Commands you can turn on or off together. The lesson has its own group, so F can close it even while the game’s keys are off.
Each midpoint miss leaves at most half the previous range, so one hundred codes don’t need one hundred guesses. After six misses, at most one candidate remains. The next scan finds it. Seven scans cover every code here, though a lucky first guess can open one safe sooner.
5.2 The Plan
- RUN or A -> Run or Pause enables Run Search -> computerTurn calls Take a Step until the trial ends.
- STEP or Space -> Step Once disables Run Search -> Take a Step makes one turn.
- Run Search changes -> runChanged -> Show In Situation swaps RUN and PAUSE.
- Watch computer -> Watch Computer keeps your result and resets the trial on the same code -> Show Human Result displays your attempt.
- F or Myth lesson -> the Input Contexts trade places -> lessonChanged stops Run Search and shows the lesson’s pieces.
5.3 Set Up
The last Set up card adds keys and places for the finished room. Its pictures are already in your Starter Kit.
INPUT CONTEXTS is new. Rename Default to Game Controls, keeping its Commands, and select its row before pressing Add Command. New Commands join that context. Make Run here with A, and Lesson with F.
Make the Myth Lesson context next, and select its row. Add Close Lesson here, with Escape. Its Command Set starts with that Command alone.
To share Lesson, select Myth Lesson’s row and pick Lesson in Reuse a Command…, below its Command Set. Both groups now share it. F works with the panel open or closed.
Game Controls starts active. Myth Lesson starts inactive. The Making page’s In later chapters passage shows the context’s name and switch.
Keep PLACE THESE beside you, but don’t place anything yet. Each part says when its pieces are ready. The lesson’s repeated lines have different words and sizes, so follow that card’s order when their turn comes.
AFEscapeDigit 0, Digit 1, Digit 2, Digit 3, Digit 4, Digit 5, Digit 6, Digit 7, Digit 8, Digit 9, Back, Clear, Scan, New Safe, Human, Computer, Step, Run, LessonLesson, Close LessonSave now, and again after each part.
5.5 The Computer Keeps Its Own Time
Now the gold mark moves without another press of STEP.
Safe Settings gains two timing fields. Add them to Safe Settings Entry, and fill their cells in Standard Safe. The first wait is runDelay, 0.25 seconds. The runInterval is 0.9 seconds between guesses, long enough to watch each card appear.
One row of the Safe Settings Data Table, made by the engine for the table's rows: lowestCode, highestCode, startEntry, scanBudget, runDelay, runInterval (the table's description says what each column means).
11005070.250.9Safe Copy gains Paused and Same Code. Add both rows now. The second one waits for the comparison part.
Scan a guess to get a clue.HIGHER THANLOWER THANUNLOCKED!OUT OF SCANSUse the remaining range.Start a new safe.Code sealed.possibilities remainpossibility remainsHIGHERLOWERUNLOCKEDCan the computer crack your code?Choose a code fromSet and lock a code first.NEXT GUESS:SOLVED INSCANSCANSPaused.Same code. Computer's turn.5.5.1 Run Search
Run Search is the chapter’s one hard idea. It owns the bell, so every way of stopping goes through it.
Choose On Enable in Add Event; its When bar uses that name. Myth supplies the heading When Enabled. It runs when this Logic turns on. Start Recurring Timer gives the bell its name, computerTurn, and reads the two timing cells. That name goes in the Action’s Timer Name with its quote marks. The Event’s Timer name is entered bare.
The first wait passes. The Recurring Timer Event runs, and calls Take a Step. One turn later, the interval passes, and it calls again. Choose Midpoint still chooses every guess, inside the same Take a Step Function you built before.
On Disable runs when this Logic turns off. Stop Recurring Timer stops the named bell. Both turning on and turning off send runChanged, so the screen can show which button belongs there. Nothing listens for that word until the next part.
The other Events are reasons to stop. A trial ends, a role changes, or the lesson opens: Run Search disables itself. Turning it off runs On Disable, so every stop reaches the same timer. The lessonChanged Event is ready before anything sends that word.
Make all six Events. For Recurring Timer, the Making page’s Events passage shows how to name the timer. Game State Changed’s condition joins three answers with ||, so any of those phases stops the search. Locked is the phase that continues.
Plays the computer's search on a timer: while this Logic is on, the computerTurn timer takes one Step every runInterval seconds. Turning it on starts the timer; turning it off stops it. It turns itself off once the safe is no longer Locked, or when a role is chosen.
Any Objectself.safeState- Timer Name
"computerTurn"- Repeat Every (s)
data('Safe Settings','Standard Safe','runInterval')- First Delay (s)
data('Safe Settings','Standard Safe','runDelay')
- Custom Event
runChanged
- Timer Name
"computerTurn"
- Custom Event
runChanged
- safeRules
self
- Action Name
safeIsOpen- Game State
Unlocked
- Action Name
scansUsedUp- Game State
Exhausted
- Action Name
settingCode- Game State
Setup
safeIsOpen.value == true || scansUsedUp.value == true || settingCode.value == true- Logic Component
Run Search- State
Disable
- Logic Component
Run Search- State
Disable
- Logic Component
Run Search- State
Disable
5.5.2 Run or Pause
Run or Pause looks at Run Search itself, with no second flag to keep in step. If the Logic is on, it turns it off and leaves the message Paused. If it’s off, a Locked safe lets it start.
A safe in Setup hasn’t got a locked code yet. An open safe has finished. In either case the Function asks you to set and lock a code first. Neither refusal spends a scan.
The Otherwise at step 5 holds a check before its If. Make it with Add Else, and add both blocks inside that Else. Step 9 is the inner If’s Else. Pick Run Search in each Logic Component list, as you did with the role Logic.
Pauses the computer's search if Run is on; otherwise turns Run on, if a locked code is waiting to be cracked.
safeStateData StructureSafe State- Action Name
runIsOn- Applies to
safeRules- Logic Component
Run Search
runIsOn.value == true- Applies to
safeRules- Logic Component
Run Search- State
Disable
- Variable
$message- Value
data('Safe Copy','Paused','text')
- Action Name
safeIsLocked- Applies to
safeRules- Game State
Locked
safeIsLocked.value == true- Applies to
safeRules- Logic Component
Run Search
- Variable
$message- Value
data('Safe Copy','No Code Locked','text')
5.5.3 Step Once
STEP needs a quiet moment to itself. Its helper stops the bell before your turn, so a timer can’t add another guess beside yours.
Takes one Step by hand: Run is turned off first if it is on, so the computer makes exactly this one turn.
safeStateData StructureSafe State- Applies to
safeRules- Logic Component
Run Search- State
Disable
- safeRules
safeRules
5.5.4 Take a Step
Take a Step keeps the midpoint and scanner you built. The Function needs no rebuilding.
5.5.5 Human Role and Computer Role
The computer’s keys use the new helpers. Computer Role gives its turns to the bell or your finger, with one helper for each. Human Role hears those Commands too, but answers with No Code Locked. Your human search stays in your hands.
What the controls do while the human cracks the safe: Enter scans the entry and R starts a new safe; Space and A only say that the computer needs a locked code. Choose Human Role turns this Logic on.
Any Objectself.safeState- safeRules
self
- safeRules
self
- Variable
$message- Value
data('Safe Copy','No Code Locked','text')
- Variable
$message- Value
data('Safe Copy','No Code Locked','text')
What the controls do while the computer cracks the safe: Enter locks the code, Space takes one Step, A runs or pauses the search, and R goes back to Setup for a new code. Choose Computer Role and Watch Computer turn this Logic on.
Any Objectself.safeState- safeRules
self
- safeRules
self
- safeRules
self
- safeRules
self
- safeRules
self
Attach Run Search to Safe Rules now, and turn its Attached Logic switch off. It should wait for you to press RUN. Safe Rules’ whole card comes later, once Lesson Keys is ready.
Run the game, press C, and lock 100. Press A. The cards arrive one after another. Press A again before the last one, and the count holds still. Space makes one turn and leaves it paused.
5.6 RUN Gives Way to PAUSE
The timer works, and the room needs to show whether it’s running.
Screen Layout gains humanDone and running. Add their fields to Screen Layout Entry, then fill every changed cell on the table’s card. The humanDone column keeps the human’s pieces visible after the attempt ends. The running column keeps the computer’s readout visible while RUN gives its place to PAUSE.
One row of the Screen Layout Data Table, made by the engine for the table's rows: human, codeSetup, searching, solved, outOfScans, humanDone, running (the table's description says what each column means).
YesYesNoNoNoYesNoYesNoNoNoNoYesNoYesNoNoNoNoYesNoYesNoNoNoNoYesNoYesNoNoNoNoYesNoNoYesYesYesYesNoYesNoYesNoNoNoNoNoNoYesNoNoNoNoNoNoNoYesYesYesNoYesNoNoYesNoNoNoYesNoNoYesYesYesNoYesNoNoYesYesNoNoYesNoNoYesNoYesNoYesNoNoYesNoNoNoYesNoNoNoYesNoNoNoNoNoYesNoNoNoNoNoNoNoNoNoNoYesNoNoNoNoNoYesNo5.6.1 Current Situation
Current Situation learns both new names. Inside its computer branch, the last check asks whether Run Search is enabled. If so, running replaces searching. Outside the computer branch, an Unlocked or Exhausted trial answers humanDone.
Check the new nesting against this whole card. Add steps 17 and 18 through step 4’s Add Inside Then, at the end of that True line. Step 19 goes inside the new If’s True line. Now give step 4 an Else. Use Add Else, then Add Inside Else for steps 21, 22 and 23. Step 24 belongs inside step 23’s True line. Return still sits last, at the very left, outside both branches.
Answers which situation the game is in, as the name of a Screen Layout column: human or humanDone in the Human role; in the Computer role codeSetup, searching, running, solved or outOfScans for the phase of the trial and whether Run is on.
safeStateData StructureSafe State- Type
Text- Name
situation
- Variable
situation- Value
'human'
- Action Name
computerCracks- Applies to
safeRules- Logic Component
Computer Role
computerCracks.value == true- Action Name
inSetup- Applies to
safeRules- Game State
Setup
inSetup.value == true- Variable
situation- Value
'codeSetup'
- Action Name
inLocked- Applies to
safeRules- Game State
Locked
inLocked.value == true- Variable
situation- Value
'searching'
- Action Name
inUnlocked- Applies to
safeRules- Game State
Unlocked
inUnlocked.value == true- Variable
situation- Value
'solved'
- Action Name
inExhausted- Applies to
safeRules- Game State
Exhausted
inExhausted.value == true- Variable
situation- Value
'outOfScans'
- Action Name
runIsOn- Applies to
safeRules- Logic Component
Run Search
runIsOn.value == true- Variable
situation- Value
'running'
- Action Name
safeIsOpen- Applies to
safeRules- Game State
Unlocked
- Action Name
scansUsedUp- Applies to
safeRules- Game State
Exhausted
safeIsOpen.value == true || scansUsedUp.value == true- Variable
situation- Value
'humanDone'
- Value
situation
5.6.2 Show In Situation
Show In Situation hears runChanged now. Its new Event calls Show For Situation with the same Arguments as its other two Events. That word Run Search sends finally has a listener.
Shows this piece only in the situations its row of the Screen Layout table picks (the keypad, the SCAN and LOCK CODE buttons, the RUN and PAUSE buttons, the Watch computer button, the computer's readout, and the rest), and hides it otherwise.
Any Object- piece
self- safeRules
@self.safeRules- layoutRow
@self.layoutRow
- piece
self- safeRules
@self.safeRules- layoutRow
@self.layoutRow
- piece
self- safeRules
@self.safeRules- layoutRow
@self.layoutRow
Make Run Button and Pause Button like Step Button, with Safe Button and Show In Situation attached to each. Each sends its own word and reads its own Screen Layout row.
Window / UIUIX 146, Y 51RUN18Bold#F5E9CACenterVector-1Safe GoldX 146, Y 51Safe RulesRun ButtonrunClickedWindow / UIUIX 146, Y 51PAUSE18Bold#F5E9CACenterVector-1Safe GoldX 146, Y 51Safe RulesPause ButtonpauseClicked5.7 The Same Safe, Two Searches
Your attempt ends, and the computer gets the code you had.
Safe State needs somewhere to keep your result. Add humanScans and humanUnlocked. They remember the count and whether the safe opened. Reset Trial leaves them alone, as it leaves the code alone.
What the Safe Rules Object carries for its Logic to share. code: the secret code that opens the safe. startsNewEntry: true when the next digit typed starts a new entry instead of adding to the one shown. clue: what the last scan told: 1 the code is higher than the guess, -1 lower, 0 the guess is the code. humanScans and humanUnlocked: the result of the human's last finished attempt, kept by Watch Computer: how many scans it took, and whether it opened the safe.
5.7.1 Start Code Setup
A different code needs a clean comparison. Start Code Setup now clears humanScans before entering Setup. That zero tells the result line there is no human attempt to display. Add the block between Reset Trial and Set Game State, using their round handles.
Starts a fresh trial in the Computer role: the player types the code the computer will crack, then locks it.
safeStateData StructureSafe State- safeRules
safeRules
- Component Value
safeRules.safeState.humanScans- Value
0
- Applies to
safeRules- Game State
Setup
- Variable
$message- Value
data('Safe Copy','Choose a Code','text')
5.7.2 Watch Computer
Watch Computer is the handover. Before it resets the trial, it keeps your count and outcome in Safe State. Then Computer Role takes over, and Reset Trial clears the range, scans and record. The secret code stays where it was.
The check’s answer is humanUnlocked.value. The field at safeRules.safeState.humanUnlocked keeps that answer after this Function ends. Their shared name describes the same fact in two places.
The trial goes straight to Locked. There is no setup keypad, because the computer is searching your old safe. The entry becomes dashes, leaving the readout to show the computer’s guesses. The message says Same code. Computer’s turn. Last, roleChosen tells the room to follow the new role.
Hands the human's safe to the computer after the human's attempt has ended: keeps the human's result, turns the Computer role on, and starts a fresh trial on the same code, already locked, so the computer searches it at once.
safeStateData StructureSafe State- Component Value
safeRules.safeState.humanScans- Value
$scans
- Action Name
humanUnlocked- Applies to
safeRules- Game State
Unlocked
- Component Value
safeRules.safeState.humanUnlocked- Value
humanUnlocked.value
- Applies to
safeRules- Logic Component
Human Role- State
Disable
- Applies to
safeRules- Logic Component
Computer Role
- safeRules
safeRules
- Variable
$entry- Value
0
- Applies to
safeRules- Game State
Locked
- Variable
$message- Value
data('Safe Copy','Same Code','text')
- Custom Event
roleChosen
5.7.3 Write Human Result
Write Human Result reads those kept facts. It shows them only while the computer plays and a human count remains. The new trial’s scans can change without changing your old result.
The line has its own Data Structure, Result Line. scansUsed holds your count, scanWord supplies SCAN or SCANS, and outcome supplies the ending. The Text puts them together, as Search Readout put its own fields together.
What the human's result line shows, written by Show Human Result. scansUsed: how many scans the human's attempt took. scanWord: SCAN or SCANS. outcome: UNLOCKED, or OUT OF SCANS.
The two Ifs inside the main True line pick the grammar and the outcome separately. Step 8 follows step 4’s If. Add it from step 2’s Add Inside Then, and do the same for Set Visible at step 12. The outer Else hides the line when there is no result to show.
Shows the human's kept result on the result line while the computer searches the human's code (after Watch computer), and hides the line otherwise. line: the text that shows the result. safeRules: the Object whose Safe State keeps the human's result (humanScans, humanUnlocked).
resultLineData StructureResult LinesafeStateData StructureSafe State- Action Name
computerCracks- Applies to
safeRules- Logic Component
Computer Role
computerCracks.value == true && safeRules.safeState.humanScans > 0- Component Value
line.resultLine.scansUsed- Value
safeRules.safeState.humanScans
safeRules.safeState.humanScans == 1- Component Value
line.resultLine.scanWord- Value
data('Safe Copy','One Scan','text')
- Component Value
line.resultLine.scanWord- Value
data('Safe Copy','Several Scans','text')
safeRules.safeState.humanUnlocked == true- Component Value
line.resultLine.outcome- Value
data('Safe Copy','Card Unlocked','text')
- Component Value
line.resultLine.outcome- Value
data('Safe Copy','Out of Scans','text')
- Applies to
line- Visible
true
- Applies to
line- Visible
false
5.7.4 Show Human Result
Show Human Result listens for roleChosen and Game State Changed. Either change can make the kept result relevant, or end its time on screen. Write Human Result reads the stored facts for either Event.
Shows the human's result beside the computer's search after Watch computer, and hides it again when a role is chosen or a new code is set up.
Any Objectself.resultLine- line
self- safeRules
@self.safeRules
- line
self- safeRules
@self.safeRules
Attach Result Line before the Logic on Human Result, and use the field names alone inside its Text’s braces. They need no dollar sign. The new button sends watchComputerClicked.
Window / UIUIYOU: {scansUsed} {scanWord} / {outcome}14Bold#F5CD73VectorResult LineSafe RulesWindow / UIUIX 219, Y 40Watch computer18Bold#F5E9CACenterVector-1Safe GoldX 219, Y 40Safe RulesWatch Computer ButtonwatchComputerClickedAdd On Watch Computer Clicked to Button Clicks from its earlier Changes card. Place both new Objects hidden, leaving Screen Layout to reveal the button when your attempt ends.
Finish an attempt in the Human role, then click Watch computer to hand the same safe over. Your result appears beside the safe, and the computer’s counter starts fresh. Press RUN and watch it search the same code.
5.8 A Lesson Over the Room
Last, give the room a place for someone to read what made that search work.
5.8.1 Open Myth Lesson
The game needs to stop listening to your keys. Open Myth Lesson trades Game Controls for Myth Lesson, then sends lessonChanged so the panel sees the finished switch. Run Search hears the same word and stops its timer.
Set Input Context Active has an Input Context list and an Active switch. Pick each group there. Active false means off. With no Active line, keep the switch on, as it starts. That’s step 2 here.
The card still prints Applies to safeRules, but the block has no Object box. Leave that line out. Check Input Context Active has no Object box either. Both ask about a group that belongs to the whole game.
Opens the Myth Lesson: the game's controls turn off (the Game Controls Input Context), the lesson's keys turn on (the Myth Lesson Input Context), and lessonChanged tells the lesson's pieces and Run Search.
safeStateData StructureSafe State- Applies to
safeRules- Input Context
Game Controls- Active
false
- Applies to
safeRules- Input Context
Myth Lesson
- Custom Event
lessonChanged
5.8.2 Close Myth Lesson
Close Myth Lesson trades the groups back while keeping every fact of your old trial where it was. Run Search hears lessonChanged again and stays off, so closing the panel never starts another guess by surprise.
Closes the Myth Lesson: the lesson's keys turn off, the game's controls turn back on, and lessonChanged tells the lesson's pieces and Run Search.
safeStateData StructureSafe State- Applies to
safeRules- Input Context
Myth Lesson- Active
false
- Applies to
safeRules- Input Context
Game Controls
- Custom Event
lessonChanged
5.8.3 Open or Close Myth Lesson
One button can do either job. Open or Close Myth Lesson asks whether the Myth Lesson context is active, and calls the Function for the other state. There is no separate lesson flag to forget.
Closes the Myth Lesson if it is open, and opens it otherwise. F and the Myth lesson button call it.
safeStateData StructureSafe State- Action Name
lessonIsOpen- Applies to
safeRules- Input Context
Myth Lesson
lessonIsOpen.value == true- safeRules
safeRules
- safeRules
safeRules
5.8.4 Lesson Keys
F brings you back too. Lesson Keys listens to that shared Command, whichever group is active. Escape belongs only to Myth Lesson, so it closes the panel without changing the room’s other keys.
Lets the keyboard open and close the Myth Lesson: F opens it or closes it, and Escape closes it. The Myth lesson and Close buttons call the same Functions.
Any Objectself.safeState- safeRules
self
- safeRules
self
Attach Lesson Keys to Safe Rules. The Object’s whole card below shows its final Logic list. Run Search and Computer Role still start turned off. Button Clicks can now get On Myth Lesson Clicked and On Close Lesson Clicked from its Changes card.
X 0.8, Y 0.8Safe StateLay Out Scan RecordLay Out Scan Record DataCode MarkScan CardCard GuessCard Clue5.8.5 Show With Lesson
The panel follows lessonChanged. Show With Lesson asks the Myth Lesson Input Context whether each piece of the panel should show. There is no list of eleven lines to keep in the Function that opens them.
Shows this piece of the Myth Lesson while the lesson is open, and hides it while it is closed.
Any Object- Action Name
lessonIsOpen- Input Context
Myth Lesson
lessonIsOpen.value == true- Visible
Yes
- Visible
No
Myth Lesson Panel is the dark background. Lesson Line is one Text Object, placed repeatedly with its own words. Both carry Show With Lesson. The panel’s card has no UI Interaction, so remove that component if it’s attached.
Window / UIUIX 910, Y 606-1Safe PanelX 910, Y 606Window / UIUIBoth players call the same Scan Guess Function.21Medium#E8EEF0VectorThe two buttons keep worksInLesson on in their Shared Variables. Myth Lesson Button can open or close the panel, and Close Lesson Button closes it. That is the permission Safe Button was waiting for.
Window / UIUIX 211, Y 40Myth lesson18Bold#F5E9CACenterVector-1Safe ButtonX 211, Y 40Safe RulesYesmythLessonClickedWindow / UIUIX 110, Y 42Close18Bold#F5E9CACenterVector-1Safe ButtonX 110, Y 42Safe RulesYescloseLessonClickedFind PLACE THESE in the Set up card above, and place the lesson’s pieces in that order. Each Lesson Line’s Text, Font Size and Color belongs to that placement. Use Edit Object Locally for its Text / UI changes, then Back to Scene before placing the next. A line without an override keeps those words.
For each lesson placement, select it in the Scene and open Rendering in its Properties. Type its Z-Index there, keeping the panel and words above the room. Myth Lesson Button starts visible. It opens the rest.
Run your game and press F, and the lesson you built covers the room. Try a digit and Space: nothing underneath changes. Escape closes it, and the safe is still waiting where you left it.
Run it and watch these moments, in order.
- Press C, lock 100, and click RUN. The first scan arrives after about 0.25 seconds, then another every 0.9 seconds. PAUSE replaces RUN.
- Click PAUSE before the search ends, and look for Paused in the message under the safe. Wait a few seconds: the range, count and cards stay still.
- Press Space. One new card appears, and RUN stays visible. Press A to continue. The safe opens within seven scans, and no eighth card appears.
- Press R, type 50, lock it, and press A to open the safe on the first scan. The readout uses SOLVED IN 1 SCAN.
- Press H. Watch computer is hidden while your attempt is in progress. Scan until the safe opens, or spend your seven scans.
- Click Watch computer and look for the message that says the computer is taking its turn on the same code. Your old result appears as YOU: with its count and outcome. The computer’s counter starts at 0 / 7.
- Let the computer run. Its final FOUND CODE is the code your safe held. Your result stays beside it throughout the search.
- Press R. Setup returns, and the kept human result disappears.
- Lock 100 and start RUN again, then press F before the search reaches the last card. The lesson opens, and the search stops.
- While the panel is open, press digits, Enter, Space, A, R, H and C. Click a game control outside the panel, such as a role tab. Nothing changes underneath.
- Close with Escape. The old range and count remain, and RUN waits for you. Open again and close with F, then try the two lesson buttons.
The timer calls the turn you already built. The turn uses the scanner both players share. Watch Computer keeps the code and gives that scanner a fresh trial. Your result waits beside it.
Binary search needs truthful clues and an ordered range. Each midpoint miss discards at least half the candidates, while the secret remains inside. From one hundred codes, six misses leave at most one. One more scan opens it.
The timer decides when to ask, while Choose Midpoint supplies the guess without ever reading the secret code. Slowing the timer changes what you can watch, and leaves the search rule alone.
5.9 If It Didn’t Work
The last pieces connect to several things you built earlier. A missed connection is normal. Watch one moment, and make one correction before trying again.
Does RUN start when the game opens? Run Search’s Attached Logic switch on Safe Rules should start off, waiting for your press. Turn it off, save, and begin a new run.
RUN does nothing? First lock a code in the Computer role. Then check Run Search’s On Enable and Recurring Timer Events. Their timer names must match computerTurn. A block standing apart from the line needs Connect to Sequence.
The scans continue after PAUSE? Look at On Disable’s Stop Recurring Timer, and compare its name with the timer On Enable started. Correct that name, run again, and pause between two cards.
Does PAUSE remain after the search stops? Look for runChanged in Show In Situation, the Event that listens when Run Search turns on or off. Check the running column too: Pause Button is Yes there, Run Button is No. Try the switch again.
Does Watch computer give a different code? Look at its reset call, before the new trial starts. Reset Trial leaves the code alone, while Start New Safe would draw a different code for the computer. Restore Reset Trial, then finish another human attempt and compare again.
Your result vanishes after the computer’s first scan? Write Human Result reads humanScans from Safe State, not the new $scans. Check that field path and try the handover again.
F opens the panel but can’t close it? Check both context lists for Lesson, the Command that belongs in each group. Put it in Myth Lesson’s Command Set too, and F can get you back.
A button still works under the lesson? Safe Button’s new If must hold its old trigger, with worksInLesson on only for the lesson’s two buttons. Check that nesting first. Digit Key uses the separate check in Type Its Digit. Fix the one you clicked, then open the panel again.
The lesson’s lines all change together? You edited Lesson Line itself instead of a placement. Restore the Object from its card, then change each placement with Edit Object Locally. Its words become its own again.
The catch-up download in the Goal holds the finished game. Compare one piece at a time with yours, and keep what you learn from the difference.
Give the computer a pace of your own. Change runDelay or runInterval in Safe Settings, then watch the same code again. What pace lets you see every clue?
Or make a different lesson panel for someone who will play your game. What do you want them to notice? Use your own words and examples, with the Functions you’ve made beside them.
In Chapter 1, nothing could ask the safe about its code. Now the room you built asks, remembers, compares, and waits while someone learns from its clues. It’s yours to change.
