Past-paper question · 2015 May-June · Paper 23 · Q2(d)(ii)

Question 2(d)(ii) 2015 · May-June · Paper 23 · 8 marks

Question 2

Part (d)

(ii)

Question 2

Ali has designed a board game.

The board consists of numbered squares.

Slides and ladders connect some of the squares.

An example layout of a board is:

30 29 28 27 26

21 22 23 24 25

20 19 18 17 16

11 12 13 14 15

10 09 08 07 06

01 02 03 04 05

The object of the game is for a player to move from the bottom square (Square 01) to the top square (Square 30).

A
roll of a 6-sided die determines how many squares the player moves.

The table below shows example moves. These use the board layout above, with the player currently on Square 04.

Number rolled by die Square moved to Consequence Final position 2 06 – 06 The base of a ladder, so 3 07 19 climb to top of ladder The top of a slide, so 6 10 03 move down the slide

Ali plans to write a program to test different board designs. Each board design will have different numbers, positions and lengths for the slides and ladders.

The program is to test each board design to check that it is possible to complete the game in a reasonable number of moves.

For each board design, the program will simulate playing the game 1000 times and report the average number of moves.

Question 5

(ii)

The function NumberOfMovesInThisGame counts how many moves the player took to

complete the game and returns this value.

The game ends when the player reaches the final square (Square 30).

If a die roll produces a number that would go beyond the final square the die roll counts as a move but the player’s position remains as before.

Complete the pseudocode on the next page.

Question 9

FUNCTION NumberOfMovesInThisGame()

DECLARE ..........................................................................................................................................

DECLARE ..........................................................................................................................................

DECLARE ..........................................................................................................................................

PlayerPosition ← .....................................................................................................................

MovesSoFar ← ..............................................................................................................................

//

REPEAT

NumberRolled ← ...................................................................................................................

MovesSoFar ← .......................................................................................................................

// check that move does not go beyond final square

IF ..............................................................................................................................................

THEN // make move

PlayerPosition ← ..................................................................................................

// check for slide or ladder and, if required, move

........................................................................................................................................

........................................................................................................................................

........................................................................................................................................

........................................................................................................................................

ENDIF

UNTIL ..............................................................................................................................................

//

...........................................................................................................................................................

ENDFUNCTION

[8]

Question 10

Reveal official mark-scheme answer Official mark-scheme answer for 2(D)(II)Official mark-scheme answer for 2(D)(II)

Official answer for Question 2

Part (d)

(ii)

(ii)

Marks as follows:

  • declaration of local variables
  • Initialisation player position
  • initialise and update MovesSoFar
  • Boolean expression in IF statement
  • update player position
  • update position if slide or ladder
  • Boolean expression following UNTIL
  • RETURN value
✓
FUNCTION NumberOfMovesInThisGame()
✓
DECLARE PlayerPosition : INTEGER
✓
DECLARE MovesSoFar : INTEGER
✓
DECLARE NumberRolled : INTEGER
✓
PlayerPosition 1
✓
MovesSoFar 0
✓
REPEAT
✓
NumberRolled RANDOM(5) + 1
✓
MovesSoFar MovesSoFar + 1
✓
// check that move does not go beyond final square
✓
IF PlayerPosition + NumberRolled <= 30
✓
THEN // make move
✓
PlayerPosition PlayerPosition + NumberRolled
✓
// check for slide or ladder and, if required, move
✓
// IF Board[PlayerPosition] > 0
✓
THEN
✓
PlayerPosition Board[PlayerPosition]
✓
ENDIF
✓
ENDIF
✓
UNTIL PlayerPosition = 30
✓
RETURN MovesSoFar // NumberOfMovesInThisGame MovesSoFar
✓
ENDFUNCTION
[8]
✓
Mark Scheme
✓
Syllabus
✓
Paper
✓
Cambridge International AS/A Level – May/June 2015
✓
9691

Question 23

Mark scheme 9691_s15_ms_23.pdf →

Topic relevance

Why this question appears here

72% assigned-topic match · Hardware › Logic gates and logic circuits

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9691_s15_qp_23.pdf

Keep practising this topic