What you learn today
- Lock two doors against each other
- Set priority
- Safe default state
Two doors, one vestibule: one leads into the workshop, the other outside into the dust storm. If both stand open at the same time, the storm blows right up to the workbench. An interlock makes sure only one door can be open at a time.
Ask first, then open
A door may only open if the other one is closed. For that the chip reads the state of the other door, not the wish:
lbn shutOut DOOR HASH("Aussentuer") Open Average
seqz shutOut shutOut # 1 = outer door is closed
and inner wantIn shutOut # inner only if outer is closed
seqz turns “open = 0” into “closed = 1”. If the outer door is missing, its value is NaN, seqz returns 0, and the inner door stays closed. Unknown counts as open here, and that is the safe side.
Setting priority
What if both wishes arrive in the same tick? Without a rule both doors read “the other one is closed” and open at the same time. That is why one door gets priority:
seqz tmp wantIn
and outer wantOut tmp # outer only if inner wants nothing
and outer outer shutIn
Here the inner door wins. Whoever stands inside should not wait in front of a closed door.
Locking against manual use
Players can also open a door by hand. Lock prevents that. Write Lock = 1 to every door that must not be open right now:
seqz tmp inner
sbn DOOR HASH("Innentuer") Lock tmp
Safe default state
Without a wish, after a restart and with every missing value the rule is: both doors closed and locked. Build every rule so that a missing or unknown value leads exactly there.
Always read the state of the other door, never just the wish for it. When switching from inside to outside, the inner door closes in one tick and only reports “closed” in the next tick. Only then may the outer door open.
In the game a door needs a moment until it is really shut. If you want to be completely safe, release the other door only after a few ticks. The on-delay from day 80 does that.
Exercise
Task
Two levers “Innen” and “Aussen” (StructureLogicSwitch, value Open) are the wishes. The doors are called “Innentuer” and “Aussentuer” (StructureCompositeDoor).
- A door only opens if its lever is on and the other door is closed (read the state).
- If both want at the same time, inside has priority.
- Every door that is not open gets
Lock= 1. - If a door or a lever is missing, nothing unsafe opens.
Hints
Hint 1
Wishes: lbn … Open Average, then sgtz – a missing lever means “does not want”.
Hint 2
Door state: lbn … Open Average, then seqz – NaN gives 0, i.e. “not closed”.
Hint 3
Inside: and inner wantIn shutOut. Outside: wish AND not wantIn AND shutIn.
Quiz
4 questions. You pass from 60 % – the server does the grading.
Complete the day
- Passed the simulator exercise
- Passed the quiz with at least 60 %
Without an account progress is saved in this browser only.
Report a mistake in this lesson
Please sign in to report. Sign in