AP CSA FRQ Guide
2012 FRQ 2: RetroBug
Write a legacy bug that remembers the location and direction from its most recent act and can restore that state when possible.
Legacy GridWorld State Restoration22 minute targetGridWorldstateobjectslegacy
Skills Tested
What this FRQ is really practicing
GridWorldstateobjectslegacy
Review these topics before attempting the problem.
Starter Approach
How to begin with your own plan
- 1Save the previous location and direction at the start of each act.
- 2Call the superclass behavior after saving state.
- 3Restore direction and, when allowed, move back to the saved location.
Attempt the problem before opening the solution.
Common Mistakes
Mistakes to watch for while writing
Saving state after the bug has already acted.
Allowing repeated restore calls to move farther back than one act.
Ignoring the occupancy rule for the previous location.
Self Check
Review questions before you submit
Declares RetroBug as a Bug.
This is a legacy GridWorld archive prompt.
Stores previous location and direction.
restore needs both pieces of state.
Uses normal Bug behavior after saving state.
The retro bug acts like a regular bug.
Checks whether the previous location can be occupied.
The prompt allows restoring only under certain occupancy conditions.
Practice Links
