A game developer is designing a grid-based movement system. The code in Figure 1 is used to inspect the 3x3 game board shown in Figure 2.
Figure 1
for row in range(3):
for col in range(3):
if getCell(row, col) == "P":
targetRow = row
targetCol = col
Figure 2
| column 0 | column 1 | column 2 | |
|---|---|---|---|
| row 0 | "Empty" | "Obstacle" | "Empty" |
| row 1 | "Empty" | "Empty" | "P" |
| row 2 | "Obstacle" | "Empty" | "Empty" |
State the purpose of the program in Figure 1.
Practise AQA GCSE Computer Science Programming concepts with exam-style questions for GCSE Computer Science. 100 questions, matched to the AQA GCSE Computer Science (8525) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.