Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help doing the following for my CS course. Here is what needs to be done, we are making a Gomuku game. The instructions

I need help doing the following for my CS course. Here is what needs to be done, we are making a Gomuku game. The instructions and everything are below.

What youre getting Ive prepared the visualization for you in a class called GomokuGUI. This class has a static method that is passed in an object that has functionality specified as in the class GomokuModel. The methods in this class thats really an interface (well talk about that in class), are the following: int getNumberOfRows() int getNumberOfCols() int getNumberInLineForWin() These methods specify the size of the game board and the number of squares in a line needed for a win. To play the default game, just have these methods return the default constants defined in GomokuModel. When testing your code, you may find it easier to experiment with a smaller board. In that case, you can change the values returned by these methods and the GUI should be able to adapt. Outcome handleClickAtLocation(int row, int col); This method is called by the GUI whenever a click occurs on the game board. Its supposed to update the state of the game board, and the return value is a value that describes the current state of the game after the newly entered click was applied. void startNewGame(); This method is called by the GUI whenever a new game is begun. It should set up whatever bookkeeping is needed to start a fresh game. CS 558 Intermediate Programming, Spring 2019 Page 2 of 4 String getBoardAsString(); This method returns a string representation of the board. The GUI calls this method whenever it needs to know what the board looks like in order to be able to redraw it. The string that is returned must match the specific format described in the interface documentation. void setComputerPlayer(String opponent); This method configures what sort of computer player (if any) will be used. Please refer to the provided javadoc documentation for GomokuModel for more information. What you have to do To get started, create a file called Gomoku.java. It should be a contain a class that implements the model interface. Ill show you in class how to make this happen. However, the main method should look something like this: public static void main ( String [] args ) { Gomoku game = new Gomoku (); if ( args . length > 0) { game . setComputerPlayer ( args [0]); } GomokuGUI . showGUI ( game ); } Three things happen in this main method: (a) Create a instance of the class you are writing. (b) Possibly configure the Gomoku object based on a command line argument. (Any command line arguments given to a Java program are available in the String array parameter of the main method.) (c) Pass the Gomoku object to a static method in the GomokuGUI class that will actually get the GUI started. There are three parts to the assignment. Each part needs to be completed before the next part is attempted. (a) Game play - Make the game work to the point that when clicking the game board, every other click yields a ring and a cross. It should not be possible to place content on a field that has already been played. Basically, in order to do this, youll have to write all the methods. However, for this part of the game, you are not required to create logic to figure out if someone wins - i.e., the handleClickAtLocation method can always return GAME NOT OVER status flag. CS 558 Intermediate Programming, Spring 2019 Page 3 of 4 (b) Win detection - Everything from the minimum required part, but added in the logic to determine who won the game. Also, the player who won the last game should get to go first in the following round. (c) Computer player - Create a rudimentary computerized player. Youll do this by making the handleClickAtLocation method also fill in a value for the player who didnt start. That will now be the computer player. For full credit, this players strategy must be better than just random placement on the board, and the player should be able to win a game at least if playing against a somewhat stupid human. The computer player should only be enabled if it was configured via the setComputerPlayer method. (You may assume that this method will not be called in the middle of a game.) An argument of NONE should disable the computer player, while an argument of COMPUTER should enable it. If you want to explore additional computer player strategies, feel free to recognize additional Strings. If you do this, please be sure to document it so that the grader will know to try them.

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

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions

Question

Explain the serial-position curve and why it occurs.

Answered: 1 week ago

Question

2. What are the components of IT infrastructure?

Answered: 1 week ago