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.
298 exam-style questions on AQA GCSE Computer Science Programming concepts. Each one has a worked solution and a mark scheme showing where the marks go.