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 ...

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 ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

  • 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