|A Natural Use of Recursion||December 2012|
|Simulating a Game of Racquetball or Volleyball|
This Web site supports one Lesson, found within an AP CS A Curriculum Module, that considers how recursion can be used to simulate a game of racquetball or volleyball.
Due to severe space limitations, the Lesson focuses on these elements:
The Lesson observes that a game simulation would naturally follow the flow of a racquetball or volleyball game. There are at least two basic approaches:
Game Flow 1: Proceed serve by serve until someone wins
Serve if server wins volley score a point if server wins game report winner else same server serves again else other team serves
Game Flow 2: Game proceeds with the sequence A serves, then B serves
Continue until someone wins A. A serves until A wins game or loses serve B. If A has not won B serves until B winds game or loses serve
Three Java programs provide support for this Lesson:
http://www.cs.grinnell.edu/~walker/racquetball/ provides an extensive discussion, separate from the Lesson in the AP CS A Curriculum Module, that considers a wide range of issues related to a full simulation of racquetball or volleyball.