Week 25 · Unit 10: Be a game developer · 3 lessons
1
Criteria for a game
Computing 5: Unit 10, pp. 129–144
GoalWrite clear criteria for a game and say how each one can be tested.
New words
criterion · one result that a program must achievecriteria · the list of results that a program must achieveevaluate · to test a program and judge whether it meets its criteriatestable · can be checked with a clear yes or no
Explanation
Before you build a game, decide what it must do. These requirements are called criteria, and one rule is a criterion. Good criteria are clear and can be tested with a yes or no. ‘The game is fun’ is hard to test. ‘The score goes up by 1 each time the basket touches the apple’ is easy to test. When the program is built, we evaluate it. We run it and check each criterion, one at a time. A criterion that passes gets a yes, and one that fails shows us where to look for a bug.
Criteria for the game ‘Catch the apple’
How to test it
1 The basket moves left and right with the arrow keys.
press each key and watch the basket
2 The apple starts at the top and falls.
click the green flag and watch
3 The score goes up by 1 when the basket touches the apple.
catch an apple and read the score
4 After a catch, a new apple starts at the top.
catch an apple and watch
5 A missed apple also starts again at the top.
let an apple fall past the basket
6 The game says ‘You win!’ and stops when the score is 5.
catch five apples
Worked examples
Weak criterion
Better criterion
The basket moves well.
The basket moves 15 steps to the left when the left arrow key is pressed.
The game is exciting.
The apple falls 10 steps each time the loop runs.
Winning feels good.
The game says ‘You win!’ when the score is 5.
Some criteria cannot be tested because they are not exact. We can rewrite them so that a yes or no is possible.
Criterion
Test
Result
1
press the left and right arrow keys
yes
2
click the green flag
yes
3
catch an apple
yes
4
watch the apple after a catch
no: it stays at the basket
After building, we test each criterion and write the result. Here is a half-built version. Three criteria pass and one fails. The failed one tells us that something is wrong after a catch.
purpose→criteria→algorithm→code→test→evaluate
Criteria come early in the plan. They are written before the algorithm and checked at the end.
Class activity
Criteria cards (pairs, paper). Choose a playground game that you know, such as hopscotch, skipping or a ball game. Each player writes 4 criteria that a good version of the game must meet. Swap papers and play a round. Your partner ticks yes or no for each criterion. Rewrite any criterion that was hard to tick, so that it can be tested with a clear yes or no.
Practice
1
Which of these criteria are testable? (a) The game is cool. (b) The score starts at 0. (c) The player has 3 lives at the start. (d) The sprite looks nice.
(b) and (c) are testable, because we can check them with a yes or no. (a) and (d) are opinions.
2
Rewrite ‘The frog moves nicely’ as a criterion that can be tested.
For example: ‘The frog moves 10 steps to the right when the right arrow key is pressed.’
3
A tester checked five criteria for a bee game. How many passed, and which ones failed?
Criterion
Result
1 The bee goes up with the up arrow
yes
2 The bee goes down with the down arrow
no
3 A flower gives 1 point
yes
4 The score starts at 0
no
5 The game stops at 4 points
yes
Three passed (1, 3 and 5). Criteria 2 and 4 failed.
4
Write three testable criteria for a game in which a rabbit collects carrots.
Answers vary, for example: The rabbit moves 10 steps when the space key is pressed. The score goes up by 1 when the rabbit touches a carrot. The game says ‘Full!’ when the score is 6.