Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This assignment will give you some experience implementing an interface, using enums, and interacting with my GUI. Problem Specification We are going to implement the

This assignment will give you some experience implementing an interface, using enums,
and interacting with my GUI.
Problem Specification
We are going to implement the game of Gomoku, also known as five-in-a-row.
The game is very similar to tic-tac-toe, only that you are playing on a larger board
(usually consisting of a squared paper). The goal is to get five-in-a-row. You are allowed to
place your marker anywhere theres an empty square on the board. The two players (X and
O) take turns to place their markers on an empty square on the board, and may try to play
offensively or defensively. The person with the best strategy and sharpest eyes usually wins
the game.
What youre getting
Ive prepared the visualization for you in a class called GomokuGUI. This class has a static
method that takes an object that has the functionality described in the GomokuInterface
interface.1 The methods in this interface are the following:
int getNumRows()
int getNumCols()
int getNumInLineForWin()
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 GomokuInterface. When testing your code, you may find it easier
1Well talk about interfaces in lecture.
1
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.
TurnResult handleClickAt(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 initializeGame();
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.
String getCurrentBoardAsString();
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.
Square getCurrentTurn()
Returns RING or CROSS, depending on which is the current player.
void initComputerPlayer(String opponent);
This method configures what sort of computer player (if any) will be used. There are three parts to the assignment. Each part needs to be completed before the
next part is attempted.
1. 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 handleClickAt method can always
return GAME NOT OVER status flag.
2. 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.
3. Computer player - Create a rudimentary computerized player. Youll do this by
making the handleClickAt method also fill in a value for the player who didnt start.
That will now be the computer player. The computer player must make legal moves,
but is not required to be particularly intelligent. For full credit, this players strategy
must be better than just random placement on the board or choosing the first available
square, and the player should be able to win a game at least if playing against a
somewhat inattentive human.
The computer player should only be enabled if it was configured via the initComputerPlayer
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

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

What are the main objectives of Inventory ?

Answered: 1 week ago

Question

Explain the various inventory management techniques in detail.

Answered: 1 week ago