Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assignment - Play a fun strategy game that only requires two players! In this game, we have an 8 x 8 board and a Knight
AssignmentPlay a fun strategy game that only requires two players! In this game, we have an x board and a Knight chess piece that starts on the top left of the board. Each player gets to move the Knight piece one square over either down, diagonal
bottom right direction or to the right of its current position a player cannot move the piece two or more squares The Knight piece can keep moving until it reaches the bottom right corner of the board. The respective player that moves the Knight to the bottom right corner of the board wins the game! In this assignment you are going to implement the winning strategy for player only.
For this assignment, you must follow these requirements.
You will create a public class called Game.
The Game Class will have the following attributes:
aD integer array that symbolizes the board to assist you with simulating the game.
bD primitive character array that stores the respective moves that will be used for
player Please store them in order of how they are presented here.
id for downward diagonal right direction index
iir for horizontal right direction index
iii. b for vertical bottom direction index
c A reference to a Random Class object. This will point to the object created by the driver and passed to the constructor. This should be used when selecting a random move for player in the selectPlayerTwoMove method.
The Game Class has a constructor that takes one parameter.
a A reference to a Random Class object that is instantiated in the driver class.
The Game class has a public nonstatic method called selectPlayerTwoMove. The method will select a random move from the D primitive character array attribute that stores the respective move from b This method is intended to select player s move only. This should not be used for player The method should return a primitive
character.
The Game class has a public nonstatic method called play. play will simulate a round of the game where player must win against player The method has no parameters. The method should return a value if the player wins the game, if not return or some other value.
You are allowed to create helper methods as long as they are not called directly from the driver file. The helper methods must be called from your solution file.
A driver file GameDriverjava has been provided for you to show you how the methods are called along with test cases to see if you get the same scenario result.
The GameDriver Class will test your play method with different test cases. The first part of the code will create different random objects with unique seeds Each object will be associated with a test case. Please remember the professor will change a few test cases when
grading your code. After the random objects are instantiated, the Game class objects are instantiated with their respective random object reference. Last, all play methods with the respective game object is invoke and will determine if player won.
CLASS DRIVER
import java.util.Random;
public class GameDriver
public static void mainString args throws Exception
different seeds for each random object
Random rand new Random;
Random rand new Random;
Random rand new Random;
Random rand new Random;
Random rand new Random;
Random rand new Random;
Random rand new Random;
Random rand new Random;
Random rand new Random;
Random rand new Random;
System.out.printlnTesting to See if Player will always win with the
random seeds.";
Game g new Gamerand;
Game g new Gamerand;
Game g new Gamerand;
Game g new Gamerand;
Game g new Gamerand
Game g new Gamerand;
Game g new Gamerand;
Game g new Gamerand;
Game g new Gamerand;
Game g new Gamerand;
ifgplay
System.out.printlnGame Pass!";
else
System.out.printlnGame Fail!";
ifgplay
System.out.printlnGame Pass!";
else
System.out.printlnGame Fail!";
ifgplay
System.out.printlnGame Pass!";
else
System.out.printlnGame Fail!";
ifgplay
System.out.printlnGame Pass!";
else
System.out.printlnGame Fail!";
ifgplay
System.out.printlnGame Pass!";
else
System.out.printlnGame Fail!";
ifgplay
System.out.printlnGame Pass!";
else
System.out.printlnGame Fail!";
ifgplay
System.out.printlnGame Pass!";
else
System.out.printlnGame Fail!";
ifgplay
System.out.printlnGame Pass!";
else
System.out.printlnGame Fail!";
ifgplay
System.out.printlnGame Pass!";
else
System.out.printlnGame Fail!";
ifgplay
System.out.printlnGame Pass!";
else
System.out.printlnGame Fail!";
Step 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