Consider the following game between two players: Both players simultaneously dec
ID: 3652699 • Letter: C
Question
Consider the following game between two players: Both playerssimultaneously declare "one" or "two". Player 1 wins if the sum of the two
declared numbers is odd and Player 2 wins otherwise. In either case the
loser in obliged to pay the winner (in dollars) the sum of the two
declared numbers. So Player 1 may lose 2 or 4 dollars and may win 3
dollars.
Write a computer program in Java that allows a user to play this game
against a computer and also allows the computer to play against itself.
The computer's strategy will be as follows. A computer player will have
a threshold variable associated with it called t that is between 0 and 1.
The computer will generate a random number between 0 and 1. If the
number is greater than t the computer will declare "two" if the random
number is less than t the computer will declare "one". If both players
are computers then each computer player will have its own threshold
variable. At the end of each round, report the amount of money each
player has won or lost so far during the session. At the end of each round
ask the user if another round should be played.
Design and implement a simulation experiment that will answer the following question: Is this a fair game? That is, in the long run should we expect each player's balance to be close to zero or is there a strategy that leads to a positive balance for one player no matter what the other player does.
Explanation / Answer
Start with a small step size and a small number of games, say STEP = 25 and NUM_GAMES = 100; this will greatly facilitate debugging. ? Once you have it all working, use STEP = 2 and NUM_GAMES = 1,000,000; this is a high variance problem! You will know you have found the optimal value when you run the simulation itself several times, and it always returns the same value. ? Try to use as many classes as possible; there is a large amount of reuse possible. ? Make everything static, so you don't have to deal with issues of instances, constructors, etc.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.