Question
how to simulate a single point squash game using r? can you help us with the following problem? A game of squash is played by
how to simulate a single point squash game using r? can you help us with the following problem?
A game of squash is played by two people: player 1 and player 2. The game
consists of a sequence of points . If player i serves and wins the point, then
his/her score increases by 1 and he/she retains the serve (for i = 1 or 2). If
player i serves and loses the point, then the serve is transferred to the other
player and the scores stay the same.
The winner is the first person to get 9 points, unless the score reaches 8 all
first. If the score reaches 8 all then play continues until one player is 2 points
ahead of the other, in which case he/she is the winner.
The object of this assignment is to simulate a game of squash and estimate
the probability that player 1 wins. Define
a = P ( player 1 wins a point | player 1 serves )
b = P ( player 1 wins a point | player 2 serves )
x = number of points won by player 1
y = number of points won by player 2
z =
1 if player 1 has the serve
2 if player 2 has the serve
We will assume that player 1 serves first.
Simulating a game (main question in which I need help)
The vector state = (x, y, z) describes the current state of the game. How do you write
function play_point that takes inputs state, a and b, simulates the play of a
single point, then returns an updated vector state representing the new state
of the game.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started