Assignment rock paper scissors

Assignment Help Basic Computer Science
Reference no: EM13853098

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(ArrayList<Integer>prev);

    /**

     * 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."

Reference no: EM13853098

Questions Cloud

Prepare a performance report for point : Prepare a performance report for Point, Inc. for the year - Point, Inc. produces men's shirts.
What is most exciting to you about studying psychology : What is most exciting to you about studying psychology? What do you hope to achieve by pursuing graduate work in psychology
Network management specialist : You are an outsourced Network Management Specialist working for an intellectual property rights law firm that has just merged another law firm that specializes in filing and defending patents.
Examined the social aspects of aging : How to Begin: This week you will incorporate feedback from the Week Three Assignment to complete the Final Research Paper. You will have formed your own conclusions about these issues, based on factual information and evidence from scholarly sources...
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).
Which sensory preconditioning works best : What are the two conditions under which sensory preconditioning works best and what is their significance.
How has the asian mattress factory been able to overcome : How has the Asian Mattress factory been able to overcome the tradeoffs between product range
What are two disadvantages of waterfall : A lot of organizations who use waterfall as their standard development methodology are looking to adopt an Agile methodology instead.  What are two disadvantages of waterfall?
Cost relationships-normal costing system : Cost Relationships; Normal Costing System - cherry Hill Glass Company employs a normal costing system.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd