Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PRACTICING INTERFACES Our goal is to practice interfaces and also to think a little bit about Artificial Intelligence! We want to be able to come

image text in transcribed
PRACTICING INTERFACES Our goal is to practice interfaces and also to think a little bit about Artificial Intelligence! We want to be able to come up with different strategies for playing Rock-Paper-Scissors and then run them against each other to see which strategy is the best. volunteers from 1. Your TA will go over how to play the game Rock-Paper-Scissors using a couple of class 2. Check out the project titled 131Fall18Lab24 3. Look at the class called Move. It's a bit odd. Note that the constructor is private! There are exactly THREE Move objects in the world at all times sors 4. Look at the interface called RPSStrategy, which has just two method prototypes: public Move getFirstMove() tPreviousMove); public Move getNextMove(Move The first method will decide which of the three moves to use in the very beginning. (It will return The idea for the second method is that you pass to it the previous move of the opponent, and it will either Move ROCK, Move.PAPER, or Move.sCISSORS). somehow compute what move to make next (either Move.ROCK, Move.PAPER, or Move.SCISSORS) 5. Look e (stupid) strategies that are provided: RockAlwaysStrategy RandomMovesStrategy trategy 6. Take a look at the PlayGame class. Note that there is a main method that will instantiate two strategies and have them play against each other a whole bunch of times. Run it 7. Now comes the fun....write a few strategy classes of your own Call the classes whatever you want, just make sure they implement the RPSStrategy interface. Edit the main method in the PlayGame class to see how your strategies do against each other, or against one of the (stupid) strategies that I have providedl HINT: You may want to use arrays as instance variables to store all of the moves that have been made historically by yourself and/or your opponent. The arrays would start off size 0, and then each time the method is called an entry would be added to the arrays. Recall that "resizing" an array amounts to making a NEW array that is one unit larger, copying all of the existing data, etc. PRACTICING INTERFACES Our goal is to practice interfaces and also to think a little bit about Artificial Intelligence! We want to be able to come up with different strategies for playing Rock-Paper-Scissors and then run them against each other to see which strategy is the best. volunteers from 1. Your TA will go over how to play the game Rock-Paper-Scissors using a couple of class 2. Check out the project titled 131Fall18Lab24 3. Look at the class called Move. It's a bit odd. Note that the constructor is private! There are exactly THREE Move objects in the world at all times sors 4. Look at the interface called RPSStrategy, which has just two method prototypes: public Move getFirstMove() tPreviousMove); public Move getNextMove(Move The first method will decide which of the three moves to use in the very beginning. (It will return The idea for the second method is that you pass to it the previous move of the opponent, and it will either Move ROCK, Move.PAPER, or Move.sCISSORS). somehow compute what move to make next (either Move.ROCK, Move.PAPER, or Move.SCISSORS) 5. Look e (stupid) strategies that are provided: RockAlwaysStrategy RandomMovesStrategy trategy 6. Take a look at the PlayGame class. Note that there is a main method that will instantiate two strategies and have them play against each other a whole bunch of times. Run it 7. Now comes the fun....write a few strategy classes of your own Call the classes whatever you want, just make sure they implement the RPSStrategy interface. Edit the main method in the PlayGame class to see how your strategies do against each other, or against one of the (stupid) strategies that I have providedl HINT: You may want to use arrays as instance variables to store all of the moves that have been made historically by yourself and/or your opponent. The arrays would start off size 0, and then each time the method is called an entry would be added to the arrays. Recall that "resizing" an array amounts to making a NEW array that is one unit larger, copying all of the existing data, etc

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago