GoalTell apart the data a simulator needs from the user and the data used to build it.
New words
user input · data the user types or chooses while the simulator runsbuilding data · facts and rules the programmer uses when making the simulator, such as limits and speedsoutput · what the simulator shows or reports back to the user
Explanation
A simulator needs two kinds of data. The first kind comes from the user while it runs. In a greenhouse simulator the user may choose how many heaters are on and how many windows are open. The second kind is used by the programmer to build the simulator. It includes facts about the real world, such as how much one heater warms the air and how much one open window cools it. These values are stored in the program, often as constants, so the user does not have to type them. The simulator combines both kinds of data and reports an output, such as the temperature. Better building data gives a more realistic simulator.
User input: heaters and windowstyped in→Simulator (uses stored facts)calculates→Output: temperature
Worked examples
Pseudocode
1CONSTANT HEAT = 32CONSTANT COOL = 23temperature ← 154INPUT heaters
5INPUT windows
6temperature ← temperature + heaters * HEAT - windows * COOL
7OUTPUT "Temperature: ", temperature
Output
Temperature: 19
The greenhouse model as pseudocode. HEAT and COOL are building data, set once as constants. heaters and windows are user input. With 2 heaters and 1 window typed, the temperature is 15 + 6 − 2 = 19.
Data
Kind
number of heaters switched on
user input
how much one heater warms the air
building data
number of windows open
user input
how much one open window cools the air
building data
starting temperature, 15
building data
Sorting the data. Each item is either typed in by the user, or stored by the programmer when the simulator is built.
heaters
windows
Temperature
2
1
19
0
3
9
3
0
24
Three runs of the same simulator. Only the user input changes. The building data stays the same.
Class activity
Greenhouse game (no computer). Partner A is the simulator and keeps the rules on a card: start at 15, add 3 for every heater, subtract 2 for every open window. Partner B is the user and chooses heaters and windows, each from 0 to 3. Partner A works out the temperature on paper. B tries to reach a temperature between 18 and 24. Record each try in a table. Then partner A secretly changes one building data value, such as the heater adding 4, and B tries again. What does B notice? If you have a computer or tablet, ask an adult to help you run a similar program.
Practice
1
A simulator lets you practise delivering parcels by bicycle. Which is user input and which is building data: (a) the route chosen by the player; (b) the top speed of a bicycle in the program; (c) how hard the player pedals; (d) how heavy a parcel can be?
Data
User input or building data?
(a) the route chosen by the player
?
(b) the top speed of a bicycle
?
(c) how hard the player pedals
?
(d) how heavy a parcel can be
?
(a) and (c) are user input, because the player chooses them while it runs. (b) and (d) are building data, because the programmer put them in when making the simulator.
2
A different greenhouse has other building data, shown in the code. What is the temperature for 2 heaters and 1 window?
Pseudocode
1CONSTANT HEAT = 42CONSTANT COOL = 33temperature ← 124INPUT heaters
5INPUT windows
6temperature ← temperature + heaters * HEAT - windows * COOL
7OUTPUT "Temperature: ", temperature
A tester says the greenhouse simulator is not realistic, because it does not know what the weather is like outside. What kind of data is missing, and how could it be added?
Building data about the outside temperature or the weather. It could be stored in the program, or the user could type it in as an extra input.
4
Write a list of three user inputs and three building data items for a simulator of a boat on a lake.
Possible answer. User input: where the player steers, how strongly the engine is run, which sail setting is chosen. Building data: how fast the boat can go, the size and shape of the lake, how strong the wind is.