Why exactly two tickets failed
A LOGIC ERROR, TRACED
The script passed validation. When a player pressed the gate button with two tickets, the output still said Gate stays closed. Here is the decision that produced it.
function run()
let price = 2
if tickets > price
log "Gate opens"
return true
end
log "Gate stays closed"
return false
endThe project supplies the shared number tickets. Read the condition aloud. “More than two” excludes two. The design calls for “at least two,” written tickets >= price. Only the comparison needs to change.
| Player holds 1 | Before the change: closed. After the change: closed. |
|---|---|
| Player holds 2 | Before: closed. After: open. This is the case that exposed the mistake. |
| Player holds 3 | Before: open. After: open. |
The three counts were run through both versions. The gate button was also checked at the exact fare. For a real gate, verify the character can actually pass, and that a second click behaves as your design intends.
