ExamBank Scot · AH Computing Science question bank · All AH Computing Science questions
15 marks · Feasibility studies and user surveys
During the analysis, the developer creates a user survey that will be completed by potential end‑users. Describe one benefit of user surveys for the: developer potential end‑users of the game. The game is for four players: Blue, Green, Red and Yellow (B, G, R and Y). All players start off the board and the winner is the first player to reach square 63. The layout of the game board is shown below. 32 57 58 59 60 61 62 63 WINNER! 56 55 54 53 52 51 50 43 44 45 46 47 48 49 42 41 40 39 38 37 36 29 30 31 33 34 35 28 27 26 25 24 23 22 15 16 17 18 19 20 21 14 13 12 11 10 9 8 1 2 3 4 5 6 7 B G R Y Players start off the board The developer uses a record structure to store details of each square with a 2‑D array of records being used to reference details of all 63 squares on the game board. The record structure will store three values: • a numeric value from 1–63 to indicate the position of a single square • either the word ‘empty’ to indicate that the square has no playing piece on it, or the name of the colour of the playing piece occupying the square • a numeric value from 0–63 to act as a pointer. The code used to implement the record structure is shown below. RECORD Square IS {INTEGER position, STRING player, INTEGER pointer} Using a programming language of your choice, declare a 2‑D array called gameboard that could be used to store the relevant details of all 63 squares on the game board. A sub‑program called initialisation() will be used to assign the initial values for each square of the game board. The pointer of each square is used to indicate whether the square is at the bottom of a ladder or the top of a snake. • A value of 0 is used to indicate that the square is not at the bottom of a ladder or the top of a snake. • A value of 1 to 63 is used to indicate that the square is at the bottom of a ladder or the top of a snake; the value stored is the position number of the square at the top of the ladder or the bottom of the snake. For example: • the pointer of square 22 is 36 • the pointer of square 51 is 0. Using a programming language of your choice, write the code used to assign the appropriate pointers to the 2‑D array variable gameboard declared in part (b) for: • square 37 of the game board • square 44 of the game board. The game board positions must follow a continuous path starting at the bottom left of the board at position 1, moving back and forward across each row of the board in the direction of the arrows, and ending up at the top right of the board at position 63. Using pseudocode, design an algorithm to assign positions 1–63 to the 2‑D array variable gameboard declared in part (b) above. The layout of the game board has been repeated below. 32 57 58 59 60 61 62 63 WINNER! 56 55 54 53 52 51 50 43 44 45 46 47 48 49 42 41 40 39 38 37 36 29 30 31 33 34 35 28 27 26 25 24 23 22 15 16 17 18 19 20 21 14 13 12 11 10 9 8 1 2 3 4 5 6 7 Several rules are used during gameplay. Rules 1 and 2 below are used to move a player and work out their new position. Rule 1: During the game, players take it in turn to roll a 6‑sided dice Rule 2: Players move forward the number of squares indicated by the dice: for example, if a player is currently on square 4 and rolls a 5, then the player moves to square 9 The algorithm for sub‑program rules12() which will be used to apply rules 1 and 2 is shown below. 1. set move = random(1–6) 2. search the 2‑D gameboard array to determine the current position of the player represented by the variable colour 3. apply rule 2 to assign a value to the variable newPosition which indicates the new position of the player Using pseudocode, refine steps 2 and 3 of the algorithm for the rules12() sub‑program. Rules 3 and 4 below are used to check for a win and process any bounce back needed. Rule 3: Players must finish exactly on square 63 to win Rule 4: If a player rolls too high a number, they ‘bounce’ back from square 63; for example, if a player is currently on square 61 and rolls a 5, then the player moves forward 2 to square 63 and then bounces back 3 to square 60 Using pseudocode, design the algorithm for the rules34() sub‑program. Rules controlling what happens when a player finishes on a square at the bottom of a ladder or the top of a snake are provided below. Rule 5: If a player is on the square at the bottom of a ladder, then newPosition must be updated to indicate that the player is now at the top of the ladder Rule 6: If a player is on the square with a snake’s head, then newPosition must be updated to indicate that the player is now at the bottom of the snake Using pseudocode, design the algorithm for the rules56() sub‑program which will be used to apply rules 5 and 6 and update value of newPosition. Explain why the test plan for this program must include integrative testing. A developer has been employed to create an online game in the style of ‘Snakes and Ladders’.
The developer can make changes to the requirements based on user opinions. The developer can incorporate user suggestions in the game. Award 1 mark for benefit for developers. Users can give feedback on features they’d like to see in the new game. Award 1 mark for benefit for end users. See sample solution below. Award 1 mark for 2D array with correct dimensions and type Square DECLARE gameboard AS ARRAY OF ARRAY OF Square < 9 x 7 array with all elements initialised as an empty record > Solutions below are based on row 0 at top of the game board. Square 37 SET gameboard[3][5].pointer TO 0 Square 44 SET gameboard[2][1].pointer TO 30 Award 1 mark for correct code used to assign both pointer values correctly. Accept solutions based on row 0 at bottom of the game board, eg Square 37 SET gameboard[5][5].pointer TO 0 Square 44 SET gameboard[6][1].pointer TO 30 Also accept solutions with row and column values swapped throughout, eg Square 37 SET gameboard[5] [3].pointer TO 0 or SET gameboard[5][5].pointer TO 0 Square 44 SET gameboard[1] [2].pointer TO 30 or SET gameboard[1][6].pointer TO 30 See sample solution below. Award 1 mark for correct use of 2D array and record structure for assignment of position numbers. Award 1 mark for assignment of continuous position numbers, taking account of odd and even rows. Accept solution based on row 0 at bottom of the game board. 1. set posNumber = 1 2. loop for each row from 8 to 0 3. if row is even number 4. 5. 6. 7. 8. else loop for each column from 0 to 6 set gameboard[row][column]. position = posNumber set posNumber = posNumber + 1 end loop 9. 10. 11. 12. end loop 13. end if for each column from 6 to 0: set gameboard[row][column].position = posNumber set posNumber = posNumber + 1 14. end loop See possible solution below. Award 1 mark for searching gameboard array to determine current position of player colour Award 1 mark for working out value of newPosition (step 4). Award 1 mark for appropriate use made of 2-D array and record data structure. 1. loop for row from 0 to 8 2. loop for column from 0 to 6 3. if gameboard[row][column].player = colour then 4. set newPosition = gameboard[row][column].position + move 5. end if 6. end loop 7. end loop See sample solution below. Award 1 mark for checking for a win and suitable action (record winner colour/ set winner to true/ display winner message (steps 1 & 2). Award 1 mark for processing bounce back (steps 4 to 5). 1. if newPosition = 63 then 2. set winner to colour 3. else 4. if newPosition > 63 then 5. set newPosition = 63 – (newPosition – 63) 6. end if 7. end if See sample solution below. Award 1 mark for correct condition to check for ladder or snake (step 1). Award 1 mark for correctly updating newPosition using stored pointer value (step 2). 1. if gameboard[row][column].pointer > 0 then 2. set newPosition = gameboard[row][column].pointer 3. end if • integrative testing would be needed for this program because it consists of several separate modules such as rules12, rules34 and rules56 which will be developed separately • it would be used to ensure that interaction between the main program and individual modules is carried out successfully and that there are no conflicts Award 1 mark for each module being developed separately. Award 1 mark for discussion of interaction between the modules or possible conflicts.