Question 3

OCR Computer Science June 2024 Algorithms and programming (H446-02)A level20 marks

On the specification

(a)
2.3 Algorithms
(b)
1.4 Data types, data structures and algorithms
(c)
2.2 Problem solving and programming2.3 Algorithms
Question text

3 A computer game has a building containing 7 rooms. There are secret passages between each room. Fig. 3 shows the rooms and the passages between the rooms represented as a graph data structure. Fig. 3 13 20 B D A 80 80 70 90 56 62 G E 0 44 20 9 15 22 F C 8 43 (a) The number in bold below each node in Fig. 3 is the heuristic value. Perform an A* algorithm on the graph shown in Fig. 3 to find the shortest path from A to G. Show your working, the nodes visited and the distance. You may use the table below to give your answer. Distance Distance travelled + Previous Node Heuristic travelled Heuristic node Final path: Distance: [7] (b) State four ways that a graph data structure is different from a tree data structure. 1 2 3 4 [4] (c)* The final game will involve multiple computer-controlled characters and interactive elements that make use of artificial intelligence to determine the moves they will make. The artificial intelligence will use heuristics to determine where the computer-controlled characters will move in the game. Discuss how heuristics can be used in algorithms. You should include the following in your answer: • the purpose of heuristics • the benefits and drawbacks of heuristics • the suitability of heuristics in algorithms within a computer game. [9]