Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Look at HW5 output and answer HW6. You are given 4 java files and do. And you will below are those codes given and I
Look at HW5 output and answer HW6. You are given 4 java files and do. And you will below are those codes given and I have done as much as I could so please modify it as you see fit and complete the program. Thank you.
Welcome, Enter 'odd' to be Odd or 'even' to be Even player: odd Enter '1' or '2' to declare a number: 1 Computer declared number: 2 You win! Would you like to continue? Enter 'y': y Enter '1' or '2' to declare a number: 2 Computer declared number: 1 You win! Would you like to continue? Enter 'y': y Enter '1' or '2' to declare a number: 2 Computer declared number : 2 You lose! Would you like to continue? Enter 'y': n Your total score: 2 Computer's total score: -2 The final winner is You!Odd-Even Simulation Recall the odd-even game from Homework 5. Your goal in this assignment is to 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 rst write a new modied 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. 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). 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. I have included a sample test class for this part called SimTest .You should not alter this class and your code must work with it. We will test your code using something similar to this. Your readMe.txt le is super important this time: Your readMe.txt le should include an explanation of what you did for each part. That is, write in plain English, instructions for using your software, explanations for how and why you chose to design your code the way you did, and most importantly how you used yoursimulations to determine whether or not the game was fair and the outcomes of your experiments. Finally, you should also cite the names of students you worked with and any external sources you used in your readMe. Use the usual submission instructions for submitting the assignment. Common Questions Here are some answers to some commonly asked questions about this problem and some tips: 0 Am I allowed to use different instance variables/move instance variables from one class to another? You can add new instance variables if you wish. You should not be moving predened instance variables from one class to another. In general, please do not change any of the scaffolding. 0 Do l need to or should I be using arrays to keep track of average winnings for different threshold combinations? No. 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. 0 What the heck does maximum minimum return mean? 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. 50 Player 1 wants to nd 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 nd a strategy with a positive valued max-min return, then the game is not fair. If you don't follow this, don't worry. We're also going to discuss this in lecture. 0 Do we need to nd the optimal thresholds for both the odd and even player? Just for the player with an advantage if there is one. 0 Do we need to print out the average winnings? Yes 0 Can I assume valid user input? Yes. 10 11 10,908 games to get good numbers 12 13 row where all values are positive for player 1 is a dominant stradegy 14 15 varying by 1 one is not enough, vry by Jog 16 11x1l rows - dont actually care about all 17 only care about the row with the maximum minimum value 18 all you care about is a row with a minimum that is positive 19 so you want to find the minimum number in a row 20 keep track of minimum in each, compare minimums, chose row with largest minimum value 21 so youre finding the min of each row and the max of those minimums 22 do the same for R2 23 use two for loops, nested for loops 24 vary one players strategy in one loop and the other in the inner loop 25 need to see if either one has a max min value that is positive. if so its not fair 26 fair if both is 0, unfair if one has positive (they have an advantage) 27 28 if t = 0, always 2 29 if t = 1, always 1 30 check corners to check code 31 32 output should be what is the max min and where? in read me interpret it 33 look at average keep doing in every spot in rowStep 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