AP CSA FRQ Guide
2008 FRQ 3: OpossumCritter
Count neighboring friends and foes, update a critter playing-dead state, and choose normal movement, its current location, or removal after three consecutive steps playing dead.
Legacy GridWorld State and Movement22 minute targetGridWorldstateobjectsinheritancelegacy
Skills Tested
What this FRQ is really practicing
GridWorldstateobjectsinheritancelegacy
Review these topics before attempting the problem.
Starter Approach
How to begin with your own plan
- 1Part A: use isFriend and isFoe to count neighbors, allowing neighbors that are neither.
- 2When foes outnumber friends, set the color to black and increment numStepsDead; otherwise set orange and reset numStepsDead to 0.
- 3Part B: select normally when alive, stay in the current location for the first two consecutive dead steps, and return null on the third.
- 4Select a location without changing any actor state in selectMoveLocation.
Attempt the problem before opening the solution.
Common Mistakes
Mistakes to watch for while writing
Treating all neighbors that are not friends as foes.
Counting total dead steps instead of consecutive dead steps.
Removing the critter directly inside selectMoveLocation instead of returning null.
Self Check
Review questions before you submit
Uses both friend and foe classification helpers.
A neighbor can be neither a friend nor a foe.
Uses black for playing dead and orange for normal behavior.
Only strictly more foes than friends triggers playing dead.
Updates the consecutive-dead-step counter.
Reset the counter to zero whenever the critter stops playing dead.
Allows normal movement, staying put, and removal.
Return null for removal instead of changing the grid in this method.
Practice Links
