AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Testing against criteria

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 criterionBetter 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.
CriterionTestResult
1press the left and right arrow keysyes
2click the green flagyes
3catch an appleyes
4watch the apple after a catchno: 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.
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.
2
Rewrite ‘The frog moves nicely’ as a criterion that can be tested.
3
A tester checked five criteria for a bee game. How many passed, and which ones failed?
CriterionResult
1 The bee goes up with the up arrowyes
2 The bee goes down with the down arrowno
3 A flower gives 1 pointyes
4 The score starts at 0no
5 The game stops at 4 pointsyes
4
Write three testable criteria for a game in which a rabbit collects carrots.
rabbitcarrot