← Teacher guide

Fake-outs and levels

An optional, harder extension of the Reaction timer. Students add decoy signals, levels with target times kept in a list, and lives, managing several pieces of state at once.

micro:bit: talk and play · Final challenge: Reaction duel · about 60 minutes · Open the student lesson

Classroom resources

Load these into Waypoints Prepare: choose Load URL and paste the copied address, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.

Students will be able to

Timing

Predict, Run, Investigate 10 min · Milestone 1 10 min · Milestone 2 15 min · Milestone 3 20 min · Make it yours 5 min

Before class

This lesson is optional: it is for students who finished the Reaction timer and Radio duel and want a harder challenge. It needs nothing new, only more of the same ideas at once. A decoy (a cross instead of the heart) appears about one round in three (pick random 0 to 2 = 0); a second true/false variable, decoy, remembers that moment. Levels use a list of target times, targets: the current level is the place in the list, so reaction < targets[level] gets harder as the level rises. When the level reaches the length of the list, the player has won. Lives count mistakes.

Running the lesson

  1. Predict: about one in three. Ask why 0 to 2 gives a third.
  2. Investigate: the list holds the rules of the game. The last question previews Milestone 3's win condition.
  3. Milestone 1: else if decoy. Read A aloud: 'if waiting, time it; else if a cross is showing, caught out; else too early'.
  4. Milestone 2: targets[level] is the key idea: a variable chooses the place in the list.
  5. Milestone 3: goals only. Encourage students to plan on paper first: when do lives go down, when does the game end?
  6. Make it yours: let students swap games and play each other's.

The hard part (on purpose)

Which check comes first in the A button, and a list of targets by level. Ask them to say the order of the questions before testing.

When students get stuck

What you will seeA question to askThe fix
Pressing on a cross shows the too-early cross, not the skull.Which is checked first in A: waiting, decoy, or else?Order: if waiting … else if decoy … else.
The level goes up even when slow.Which way round is the comparison?Use reaction < targets[level]: faster than the target.
Something goes wrong after the last level.Which places exist in targets?When level equals the length of targets, the player has won: show Champion and start again.

Answers to the checks

  1. Predict: Over many rounds, how often does a cross appear instead of the heart?
    About 1 round in 3. pick random 0 to 2 gives 0, 1 or 2 equally often, and only 0 shows the cross.
  2. Targets per level: targets is 800, 600, 450, 350, 300. What must you beat at each level?
    800, 450, 300
    The level number is the place in the list, counted from 0.
  3. After the last level: There are 5 targets. You beat level 4. What must the game do next?
    Stop: there is no place 5, so you have won (level equals the length of the list)
    Places run from 0 to 4. When level reaches 5, the length of the list, there are no targets left: the player has won.

Solutions

One possible solution for each task. Other correct programs are fine.

Milestone 1: fake-outs

The program as blocks
Show as code
let start = 0
let waiting = false
let decoy = false
input.onButtonPressed(Button.B, function () {
    waiting = false
    decoy = false
    basic.clearScreen()
    basic.pause(randint(1000, 3000))
    if (randint(0, 2) == 0) {
        decoy = true
        basic.showIcon(IconNames.No)
    } else {
        basic.showIcon(IconNames.Heart)
        start = input.runningTime()
        waiting = true
    }
})
input.onButtonPressed(Button.A, function () {
    if (waiting) {
        waiting = false
        basic.showNumber(input.runningTime() - start)
    } else if (decoy) {
        decoy = false
        basic.showIcon(IconNames.Skull)
    } else {
        basic.showIcon(IconNames.No)
    }
})

Milestone 2: levels

The program as blocks
Show as code
let start = 0
let waiting = false
let decoy = false
let reaction = 0
let level = 0
let targets = [800, 600, 450, 350, 300]
input.onButtonPressed(Button.B, function () {
    waiting = false
    decoy = false
    basic.clearScreen()
    basic.pause(randint(1000, 3000))
    if (randint(0, 2) == 0) {
        decoy = true
        basic.showIcon(IconNames.No)
    } else {
        basic.showIcon(IconNames.Heart)
        start = input.runningTime()
        waiting = true
    }
})
input.onButtonPressed(Button.A, function () {
    if (waiting) {
        waiting = false
        reaction = input.runningTime() - start
        if (reaction < targets[level]) {
            level += 1
            basic.showNumber(level)
        } else {
            basic.showIcon(IconNames.Sad)
        }
    } else if (decoy) {
        decoy = false
        basic.showIcon(IconNames.Skull)
    } else {
        basic.showIcon(IconNames.No)
    }
})

Milestone 3: lives

The program as blocks
Show as code
let start = 0
let waiting = false
let decoy = false
let reaction = 0
let level = 0
let lives = 3
let targets = [800, 600, 450, 350, 300]
input.onButtonPressed(Button.B, function () {
    waiting = false
    decoy = false
    basic.clearScreen()
    basic.pause(randint(1000, 3000))
    if (randint(0, 2) == 0) {
        decoy = true
        basic.showIcon(IconNames.No)
    } else {
        basic.showIcon(IconNames.Heart)
        start = input.runningTime()
        waiting = true
    }
})
input.onButtonPressed(Button.A, function () {
    if (waiting) {
        waiting = false
        reaction = input.runningTime() - start
        if (reaction < targets[level]) {
            level += 1
            if (level == targets.length) {
                basic.showString("Champion")
                level = 0
                lives = 3
            } else {
                basic.showNumber(level)
            }
        } else {
            lives += -1
            basic.showIcon(IconNames.Sad)
        }
    } else if (decoy) {
        decoy = false
        lives += -1
        basic.showIcon(IconNames.Skull)
    } else {
        basic.showIcon(IconNames.No)
    }
    if (lives == 0) {
        basic.showString("Game over")
        basic.showNumber(level)
        level = 0
        lives = 3
    }
})

Make it yours

Open task: any program that does what the step asks.

Stretch and support

Stretch: Make the decoy chance grow with the level: pick random 0 to (4 − level), so higher levels trick you more often.

Support: Students who find this heavy can stop after Milestone 2; the levels alone make a good game.

Exit ticket

level is 2 and targets is 800, 600, 450, 350, 300. What time must you beat, and why?

450 ms: level 2 is the place in the list, counted from 0.

What each step is for

Where it leads

The other optional lesson, Tournament, takes the Radio duel further with a scoreboard list. Class ideas: a class high-level board; students design a sixth level and argue what its target should be.