Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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 there's 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's included
I've 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 that's really an interface (we'll talk about that in class), are the following:

• intgetNumRows()
intgetNumCols()
intgetNumInLineForWin()

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.

1
• Outcome playAtLocation(int row, int col);
This method is called by the GUI whenever a click occurs on the game board. It's 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.
• voidstartNewGame();
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 getBoardString();
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.
• voidsetComputerPlayer(String opponent);
This method configures what sort of computer player (if any) will be used.
Please refer to the documentation for GomokuModel.java for more information.

To do
To get started, create a file called Gomoku.java. It should be a class that implements the model interface. I'll 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:
1. Create a instance of the class you are writing.
2. 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.)
3. 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.

2

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, you'll 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 playAtLocation method can always return GAME NOT DONE 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. You'll do this by making the playAtLocation method also fill in a value for the player who didn't start. That will now be the computer player. For full credit, this player's 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.

Attachment:- lab3.jar

Java, Programming

  • Category:- Java
  • Reference No.:- M92400020
  • Price:- $10

Priced at Now at $10, Verified Solution

Have any Question?


Related Questions in Java

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As