Ask Computer Engineering Expert

Assignment Rock Paper Scissors

This problem will be a fun application of interfaces. It revolves around  the game of Rocks, Paper, Scissors (also known in some parts of the world as RoShamBo). For those of you who are not familiar with the game, it is played between two people who we will refer to as A and B. Person A makes a selection of either rock, scissor, or paper with person B being unaware of what A will choose. Similarly, person B will make a selection of either rock, scissor, or paper with person A being unaware of what B will choose. Then, based on the selection of each, a winner is decided based on the following selection matrix:

 

B selects ROCK

B selects PAPER

B selects SCISSOR

A selects ROCK

TIE

B WINS

A WINS

A selects PAPER

A WINS

TIE

B WINS

A selects SCISSOR

B WINS

A WINS

TIE

This can be summarized as "rocks beat scissors" (since a rock can break a pair of scissors), "scissors beat paper" (since scissors can cut paper), and "paper beats rock" (since paper can cover a rock). Typically, the game is repeated many times so that players can exploit patterns in their opponents' playing styles in order to accumulate more wins.

In this exercise, you will be implementing your own strategy for playing this game. Then, I will take every student's strategy and implement a tournament to evaluate which strategy is best. THE TOURNAMENT WILL JUST BE FOR FUN AND THE OUTCOME WILL NOT AFFECT YOUR GRADE ON THIS ASSIGNMENT.

1. Consider the following interface:

 

importjava.util.ArrayList;

 

public interface RPS_Player {

 

    /**

     * integer constant representing the selection rock

     */

    static final int ROCK = 0;

 

    /**

     * integer constant representing the selection scissor

     */

    static final int PAPER = 1;

 

    /**

     * integer constant representing the selection paper

     */

    static final int SCISSOR = 2;

 

    /**

     * method that utilizes an arraylist of an opponent's previous choices to

     * make a selection of whether to play rock, scissor, or paper next.

     * @paramprev an arraylist of previous selections made by the opponent

     * @return the integer RSP_Player.ROCK, RSP_Player.SCISSOR, or 
     *         RSP_Player.PAPER

     */

    intmakeSelection(ArrayListprev);

    /**

     * method that returns name of the student who provided the 
     * implementation

     * @return student's name as a string

     */

    String getStudentName();

}

Write a class RPS_YOUR_FULL_NAME (e.g., RPS_TONY_WILLS) that implements the above interface. In the makeSelection method, you should provide an implementation of a strategy for playing this game. A simple, yet unexploitable, strategy would be to return rock, paper, or scissor (as an integer) completely at random. However, this strategy will not generally be a winning strategy since you will tie on average. The only way to consistently win is to take advantage of predictabilities/patterns in your opponent's previous selections (which will be given to you as an integer array list). An example of a more sophisticated strategy might be one that keeps count of how many times the opponent makes each choice and then makes the selection which beats the most occurring choice (i.e., if your opponent selects rock 60% of the time, your best selection might be paper). Your class should also include a default constructor that takes no parameters. I will be using this constructor to instantiate your strategy in the tournament.

ADDED CONSTRAINT: YOU ARE NOT ALLOWED TO IMPLEMENT THE RANDOM CHOICE STRATEGY AS IT IS TOO SIMPLE. I AM REQUIRING THAT YOU SOMEHOW USE YOUR OPPONENT'S PREVIOUS MOVES IN YOUR STRATEGY, I.E. DON'T IGNORE THE ARRAYLIST prev.

Your class may add additional functionalities as you see fit. One recommendation would be to add an instance field my_prev, which will keep track of your previous selections. Each match between classes will consist of 1,000 repetitions of the game. The lifetime of your RPS_Player object will be the entire duration of these 1,000 repetitions, so you will be able to keep a history of your selections should you choose to do so.

You are all very intelligent and I'm excited to see the strategies that you will come up with!

As a side note, a copy of this interface will be posted under Doc Sharing. Students are expected to adhere to this interface for credit. If I cannot create an instance of your class using the statement

RPS_Player strategy = new RPS_YOUR_FULL_NAME();

Then you will not receive credit on this assignment.

2. In this exercise, you will write a class that contains a method to simulate Ntrial (a constant defined in your class, default = 1,000) repetitions of the game between two RPS_Player objects. This method should return the difference between the number of repetitions that the first player won and the number of repetitions that the second player won. Write a main function that constructs two RPS_Player objects and runs a match of 10,000 repetitions between them.

3. Prepare a UML class diagram that shows the relationships between the classes that you have created in this homework and the two interfaces that they implement.

Submission: Please submit only java source files, word documents, and or pdf files into the appropriate dropbox. Do not place these files into any kind of container (i.e. no zip or rar files).

Tournament Method: I will be writing my own class similar to the one that you will write in problem 2. Then I will implement a round-robin style tournament in which every possible pair of student strategies will face off against each other for 1000 repetitions. Each student will receive 1 point for every win, 0 points for every tie, and -1 point for every loss. The student with the highest score will be deemed to have the best strategy.

I will be creating my own strategy and competing with you (just for fun, of course). I will also be adding some benchmark strategies including (1) a completely random strategy with all choices being equal, (2) a random strategy in which no two consecutive selections can be the same (which is very exploitable), and (3) a trivial strategy that always selects "rock."

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91422863
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As