Question: IN JAVA Consider the following game between two players: Both players simultaneously declare one or two. Player 1 wins if the sum of the two

IN JAVA

Consider the following game between two players: Both players simultaneously declare "one" or "two". Player 1 wins if the sum of the two declared numbers is odd and Player 2 wins if the sum is even. In either case the loser is obliged to pay the winner (in tokens) the sum of the two declared numbers. So Player 1 may have to pay 2 or 4 tokens or may win 3 tokens. You can imagine a single session between two players involving many games. At the end of a session, one player may have won many tokens from the other.

Determine whether or not this is a fair game. That is, is it better to be Player 1 or Player 2 or does it matter? To do this first write a modified version of the Game class so that it also allows two computer players to play a game against each other. Do this by overloading the constructor so that when a game is instantiated one may specify whether or not it is interactive or simulated (so interactive part has to work too). Since both players are computers in a simulated game each computer player will be a different object with its own threshold (instance) variable t and and its own score (tokens won or lost so far in a session). In the interactive part, the user must choose their side (odd or even) at the beginning of the session, then they can choose to play a 1 or 2 against the computer for as many rounds as they want - until the user decides to quit the session.

Write a new test class called Simulation that allows you to run some simulations (play many games of computer versus computer) using various combinations of the threshold variable t for each player. A single simulated game need not print or return anything. Check to see how much each player loses or wins for each combination of thresholds after many games. Is it better to be the odd player? The even player? Does it matter? Better here means that if enough games are played there is a strategy (threshold) that one player can use that guarantees positive average outcome regardless of the other player's strategy. We call it a fair game if there is no such strategy for either player. By using the computer vs. computer option in your program set up some extended sessions of computer vs. computer to test different combinations of Player 1's t and Player 2's t (Hint: use a nested for loop structure to vary each player's threshold). Determine if either player has an advantage and if so which player it is and determine a threshold value t* that demonstrates the advantage.

N o need to use arrays. Remember you don't need to keep track of the average winnings for every combination. Just the max-min. That is, you just need to know which strategy guarantees the maximum minimum return. What do I mean by maximum minimum return? Suppose Player 1 chooses a strategy (t=.6, for example). Player 2 will now want to choose a strategy that minimizes Player 1's average winnings over many games (ie: maximizes Player 2's average winnings). Maybe that's strategy t=.5, maybe it's t=.65, whatever it is, that's Player 2's optimal strategy given Player 1 playing with strategy t=.6 and that's the minimum return Player 1 can expect in the long run when playing with strategy t=.6 for many games. If that minimum is a positive number it means the game is not fair because it means that if Player 1 plays with strategy t=.6, no matter what Player 2 does, Player 1 will win tokens in the long run. So Player 1 wants to find a strategy (a value for t), among all possible strategies, that has a minimum return that's positive. More generally Player 1 wants to maximize their minimum return. Of course Player 2 wants to do the same. If either player can find a strategy with a positive valued max-min return, then the game is not fair.

You only have a ComputerPlayer class, Game class, the main method SimTest class (this class just makes sure that two computers can play against each other for specified amount of games) and the main method Simulation class (this class should run simulations to determine whether or not the Odd-Even game is fair and if not who has the advantage and what is a strategy that will realize that advantage).

.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!