Write a procedure that has the probability of Player A winning a volley as parameter and simulates the playing of 1000 games with Player A having the first serve on each game. Record the number of wins (including shut-outs) for each player and the percentage of wins. Also record the number of shut-outs for each player.
Write a procedure that has as parameter the probability of Team A winning a volley and then simulates the playing of 1000 games with Team A having the first serve on each game. The procedure should print the number of wins for each team and the percentage of wins. The procedure also should print the number of shut-outs for each team.
With these similarities, the following discussion will apply to either sport. Only the ending condition changes from one game to another.
Either iterative or recursive implementation of the general approach leads to an solution outline. Two of the four possible, high-level outlines follow:
Approach 1: A game is a sequence of serves
Recursive solution for a game:
I. Initialization
A. Initialize the Random Nunber Seed
B. Determine probability of A winning a volley
C. At start of simulation, neither A nor B have won,
and neither have scored any shut-outs
II. Repeat for 1000 games
A. Initially, A and B have 0 points
B. A has first serve
1. Use A's probability for probability of server
C. If neither A nor B has won:
1. Determine if server wins volley
If so,
Server wins point
Update score of correct person,
depending on server
Call II.C with same server,
probabilities, etc.
If not,
Server looses volley; other person
wins volley
Change probability of server to other
person
Call II.C with new server,
probabilities, etc.
D. Record who has won
E. Record if a shut-out has occured
III. Print results
A. Print the number of wins and shut-outs for A
Approach 2: A game is a sequence of A-serves then B-serves
Iterative solution for a game:
I. Initialization
A. Initialize the Random Nunber Seed
B. Determine probability of A winning a volley
C. At start of simulation, neither A nor B have won,
and neither have scored any shut-outs
II. Repeat for 1000 games
A. Initially, A and B have 0 points
B. Continue until A wins or B wins
1. A serves
Continue until A wins or looses serve
If A wins volley
then A scores point
otherwise, B gets serve
2. If A has not won, then B serves
Continue until B wins or looses serve
If B wins volley
then B scores point
otherwise, A gets serve
C. Record who has won
D. Record if a shut-out has occured
III. Print results
A. Print the number of wins and shut-outs for A
B. Print the number of wins and shut-outs for B
Steps for this Project:
Collaboration for this Project:
This document is available on the World Wide Web as
http://www.math.grin.edu/~walker/courses/153/project-racquetball.html