# Activity Goals

The goals of this activity are:
1. To introduce the microbit as a programming device
2. To explain why computers cannot generate truly random numbers
3. To explain how computers generate pseudorandom numbers
4. To explain the role of seed values in pseudorandom number generators (PRNG)
5. To provide examples of mechanisms that computers use to seed PRNGs
6. To develop an algorithm to generate pseudorandom numbers with a computer
7. To implement an algorithm using the micro:bit blocks language
8. To create and use a GitHub account to save your micro:bit MakeCode project
9. To create and manipulate variables in a computer program
10. To implement a mathematical formula using code

Feel free to visit these resources for supplemental background reading material.

# The Activity

## Model 1: Random Numbers

From where we stand the rain seems random. If we could stand somewhere else, we would see the order in it.
Tony Hillerman, Coyote Waits

### Questions

1. Pick three numbers from 1 to 10 at random, and write them on the board.
2. What do you notice about the distribution of those numbers?
3. How did you come up with those numbers? How did you ensure they were truly quot;random?"
4. What does it mean to be "random?"

## Model 2: Computers and Random Numbers

### Questions

1. How do computers pick numbers "at random?"
2. How do they decide when to spawn certain "random" events?
3. Is this video game player really good at the game?

## Model 3: Pseudorandom Number Generation

### Questions

1. The Linear Congruential Generator is one way to generate a pseudo-random number computationally. Choose a starting value and generate 3 random numbers using this formula.
2. What would happen if two people used the same starting value (called a "seed")?
3. How might video games generate a seed?

## Model 4: Introduction to the micro:bit

micro:bit devices are "programmable units" that have:
• electrical connections
• LED output display
• compass
• accelerometer
• speakers
• light sensors
• buttons

### Questions

1. Using the micro:bit, create variables for a, b, c, and X: call them multiplier, adder, modulus, and current.
2. Give them any values you want by setting their values in on start.
3. When the user presses the A button, set the value of the X variable (current) using the formula, and show X on the screen.
4. Is it ok that the X variable appears on the left and the right side of the equals sign? Why or why not?
5. On start, show the value of X on the screen.
6. When you're done, click on the Python tab at the top. What do you notice about each block from the original program?
You can connect the micro:bit to your computer by plugging in the USB cable. However, some computers do not have a compatible mac cable. If you don’t have an adapter, your computer may support Bluetooth, a wireless protocol that you can use to connect to the micro:bit. You can do this by holding down the A and B buttons of the micro:bit, and, while holding them down, press and release the reset button. You’ll see the words “PAIRING MODE” appear on the micro:bit display. Open a bluetooth application on your computer (on the Mac, one such program is called LightBlue), and select the BBC micro:bit to pair. The micro:bit will prompt you to press the A button and a 6-digit code will appear on the screen. Type that code on your mac and you should have access to the storage of the micro:bit! You can download your code from Makecode, and then drag the .hex file from your Downloads directory to the micro:bit disk. It will restart and launch your app automatically. Here is a video describing the process on a Mac, although the process is similar on other Bluetooth enabled computers.