CITS1001 Project 2

Check the LMS to ensure that you have the latest version.
If you have any questions about any aspect of the project, submit them to help1001.
Some corrections have been made to the project, they are as follows:
The description of second constructor in the GameViewer class now reads “Sets the
numberOfItemsToHide to 3.” instead of “Sets the numberOfItemsToHide to 40”
The test, testSelectItems, test uses .equals instead of == for string comparison to make more
robust between different environments.
The following tests have also been updated (given a mixup with x and y coordinates) –
testCheckForFoundItems, checkWhichItemsFound and testLostPieces.
Update 11 May: The isSearched method (TODO 22) should read @return true if a given piece is
a searched piece, false otherwise.
Update 11 May: The setShape method (TODO 4) should not include the comment “@return the
shape”. This is a void type method, please do not change the method header to try to return
Project Rules
Submission deadline: 5pm Friday 27 May 2022
Submit via cssubmit
Value: 20% of CITS1001
Project work to be done in pairs (pairs have been allocated).
Project published: 6 May 2022
The project task is to construct a Java program containing your solution to the following problem. You must
submit your program via cssubmit. No other method of submission is allowed. Only one submission per team is
required, but make sure it includes the names and student numbers of both partners. The name and
student numbers of both partners should be written at the top of every submitted file. If the names
are not in every file, you will be penalised.
You are expected to have read and understood the UWA Policy on Academic Conduct. In accordance with this
policy, you may discuss with other students the general principles required to understand this project, but the
work you submit must be the result of your own effort.
You must ensure that you have submitted the correct files. If the incorrect files are submitted, you
will be penalised.
You must submit your project before the submission deadline above. UWA’s Policy on Late Submission will

Project Overview
This project is to make a game called Find my Things. The computer (an AIPlayer) will place “things” at random
places (and in random orientations) on the board. At the start of the game, all of the placed “things” will be
hidden from the player. The player’s job is to find all “things” before their turns (turns remaining in Figure 1)
run out.
Figure 1: Game Started.
Figure 2: Player has taken turns.
The game takes place on a square grid. In the figures:
A blue square represents a space that has not yet been searched by the player.
A red square represents a space that has been searched by the player, but no lost “things” have been
hidden in that location by the computer (i.e. the AIPlayer).
A green square represents a space that has been searched by the player, and that part of a lost “thing”
has been hidden at that location by the computer (i.e. part of the thing has now been found).
Below the grid is a scoreboard. The scoreboard contains:
Turns Remaining: The number of turns that they player has left to find the “things”
Closest Lost Item: Displays a string showing how far away the closest lost piece is to the user’s last click
(i.e. if the piece is one space to the right of the click then this would read (x: 1, y:0).
Things to Find: Shows what “things†have been placed on the board by the computer. Each “thing”
type has a unique shape. In the example shown above, a “shoe” has been found by the user. Another item
has been partially found but not completely uncovered. And there is still a full missing piece.
Restart Game: A button that resets the board, number of turns remaining and triggers the computer to
hide three new items.
In this project, you are required to write a Java program to allow a user to play the game Find my Things.
Playing Find my Things
Please see the video demonstration for how to play Find My Things. The demonstration can be found in the
HowToPlay file provided along with the project files.
Game Specification
The following rules should be considered when writing your code.
The AIPlayer has 5 “things” to chose from when hiding items on the board. The shapes of these items are
shown in Figure 3.
When the AIPlayer is placing items on the board, 0 values can overlap, but 1 values can not (see Figure 3
for 0 and 1 values).
If a player searches a space, and does not find an item hidden at that location, their number of turns
remaining will reduce by 1.
If a player searches a space, and does find an item hidden at that location, their number of turns
remaining does not reduce by 1.

Get Your Custom Essay Written From Scratch
Are You Overwhelmed With Writing Assignments?
Give yourself a break and turn to our top writers. They’ll follow all the requirements to compose a premium-quality piece for you.
Order Now

If a player’s number of turns remaining have hit 0, they have lost the game. No further action can be
taken by the player.
To play the game again after the number of turns remaining has hit 0, the player can click the “restart
game” button.
Figure 3: Shapes of “things” that the AI Player can hide on the board.
Project Materials
Download the folder from the LMS Project 2 page. This folder contains the following.
1. Skeletons for four java classes.
GameViewer represents one interface for playing the game Find my Things.
AIPlayer represents the computer, who will hide “things” on the board at the start of every game
of Find My Things (i.e when the game is loaded or when the game is restarted).
Board represents the current state of the game board in one game of Find my Things (i.e. for each
piece on the board, does this space contain a lost item, a found item, a searched space, or an
unsearched space).
Item represents a “thing” that is hidden by the AIPlayer and must by found by the player during the
Collectively, these classes implement the game Find my Things. You are required to complete the
constructors and methods for both classes. Where the body of a constructor or method contains a
comment TODO, delete the body and replace it with code which implements the required functionality, as
described in the associated program comment. The numbers in these comments suggest an order for you
to perform these tasks.
To start the GameViewer, the defaults to use for the best game experience are:
bkSize = 40
numberOfTurns = 20
numberOfItemsToHide = 3
2. Two fully-written Java classes. You do not need to change or submit these classes, but you do need to
understand the functionality that they provide.
Piece enumerates the possible states of a square in the grid.
SimpleCanvas will help to perform screen and mouse management, and draw various parts of the
3. Four JUnit test classes, which are provided for you to check your code. Note that the test cases are not
complete; a method that gets all green ticks is not guaranteed to be completely correct. Additional test cases
will be used for marking and it is your responsibility to thoroughly test your code.
IMPORTANT: Some code in the skeletons has been provided for you. It is imperative that you do not
change any of the code in the constructors / methods that have been written for you.

Project Management Tips
Before starting the project, students are expected to have
studied the lectures and the relevant chapters of the text,
completed the assigned labs during Weeks 2-9,
read and understood the whole of this project description,
read and understood all relevant UWA policies.
Note especially that the Game of Life lecture and the Fifteen Puzzle lab will be very helpful. Submit any
questions about any of this to help1001.
It is recommended that you tackle the project tasks in the order indicated; that you compile frequently; and
that you test and run the code after completing each method, to ensure your code behaves as you think it
ought, and does not fail any tests. If you are stuck on a method, it is often a good idea to look in the lecture
material or in the text for an example method which is similar in some way to the one that is confusing you.
You can gain good marks even if you do not complete all the methods, so long as the code you have written
compiles and runs. But if you submit a large body of code that does not compile or that crashes, then few
marks can be awarded.
Hints and tips about the various methods may be uploaded here from time to time. Whenever that happens,
the document version number will be updated.
Hints for the Item Class
Do not modify the names of the field variables or the parameters in the constructor. There is a way to
initialise the field variables, even through the constructor’s parameters have the same name. Your job is is
figure out how to do this.
Hints for the Board Class
To complete this class, you need to understand the enum class Piece. Read the lecture on enumerated
Some of the methods in this class require you to throw an exception. Do not change the method header
to achieve this or you will be penalied. There is a way to do this without changing the method header.
Hints for the AIPlayer Class
DO NOT CHANGE THE CONSTRUCTOR IN THIS CLASS. It has been provided for you. Use the constructor
to help you to understand what you need to do in the methods.
You will need to look back in your notes to figure out how to generate random values. The range of the
random values generated is especially important here.
Instructions for each of the methods have been laid out for you in the code skeleton. To complete the
methods, make sure you understand what it is asking you to do before you begin.
Hints for the GameViewer Class
1. DO NOT CHANGE THE FIRST CONSTRUCTOR IN THIS CLASS. It has been provided for you. Use the
constructor to help you to understand what you need to do in the methods.
2. For the second constructor in this class, try not to repeat the code in the first constructor. Your job is to
figure out how to do this.
3. Similar to the AIPlayer class, instructions for each of the methods have been laid out for you in the code
skeleton. To complete the methods, make sure you understand what it is asking you to do before you

Project Submission
Submit your four completed .java source files by the submission deadline above via cssubmit. Do not submit
anything else. No other method of submission is allowed. Only one submission per team is required, but
make sure it includes the names and student numbers of both partners.
The files that you must submit are:
– and,
Please do not submit any additional files (unless you have completed an extension). If you submit
additional files you will be penalised.
The file names, class names, and method signatures in your submitted code must match the original
specifications exactly. The marking process is partly automated, and any changes you make which complicate
this process will be penalised. If your code cannot be compiled with the original JUnit test cases provided, your
submission will be penalised. It is ok to add other methods if you like, so long as you do not change the
signatures of existing methods.
Common mistakes are to submit .class files in place of .java files, or to submit the test classes in place of your
code. If you do one of these (or something similar), you will be notified by email as soon as we become aware,
but you will be due for any applicable late penalty up to the time you re-submit. cssubmit makes it easy to
check your files after you have submitted them – do it!
Project Assessment
Your submission will be assessed on
completeness: how many of the methods you have written;
correctness: whether your methods implement the specifications exactly;
clarity: whether your code is well-constructed and clear to read.
JUnit testing classes are provided to help you check your program before submission, but the correctness of
your program remains your responsibility.
Completeness and Correctness guidelines (/72)
The marks available for each constructor and method are as follows. These numbers give some indication of
how difficult we believe each component is.
Item constructor (1), getType (1), getShape (1), setShape (1), setFound (1), getIsFound (1),
getLocationX (1), getLocationY (1), setLocation (1), rotate90Degrees (3).
Board first constructor (1), second constructor (2), getBoardSize (1), isPiece (1), getPiece (1),
isLostItem (1), setLostItem (1), isVacant (1), setVacant (1), isFoundItem (1), setFoundItem (1),
isSearched (1), setSearched (1), searchSpace (2), getClosestItem (5), checkForFoundItem (3),
getFoundItemsList (2)
selectItems (3), selectLocation (2), selectOrientation (2), tryItemLocation (3), setLostPieces (3),

AIPlayer startGame (4).
Game Viewer
second constructor (1), restartGame (2), getNearestPiece (2), getTurnsRemaining (1),
reduceTurns (1),
drawGameOutcome (1), refreshBoard (3), takeTurn (4), mousePressed (2)
Methods will be assessed independently, so e.g. even if your searchSpace is faulty, other methods that use
searchSpace could still get full marks.
Completeness and correctness will be evaluated (partly) automatically using JUnit tests. You should, therefore,
try to ensure the following.
The code passes the tests as per the specification.
Validation should be exactly what is required by the assignment specification. Incorrectly rejecting a
parameter is incorrect and will be penalized, so do not add extra validation that is not asked for.
Do not print things to System.out or System.err that are not asked for. Use the BlueJ debugger rather
than print/ln statements for debugging your code.
Do not change the given file names or class names, or modify the signatures of existing methods.
Clarity guidelines (/15)
Keep code as simple as possible for the job it is required to do.
Use appropriate programming constructs for all implementations.
Do not add fields to the classes, except if completing the project extension.
Give appropriate names to all variables.
Lay out code neatly and with appropriate indentation, with lines no longer than eighty characters.
If a method is particularly complex, break it up with private helper methods.
If the logic of a method is complex, add a brief comment explaining your strategy; but otherwise, do not
comment code unnecessarily.
Make sure booleans are used correctly
If the markers struggle to understand your code, you are likely to be penalised. After a method is working, it is
good practice to examine the code carefully to see if there are any ways in which you can simplify it or make it
The quickest way to get help with the project (unless you are sitting in a lab session) is via help1001. You can
ask questions, browse previous questions and answers, and discuss all sorts of topics with both staff and other
Please read and follow these guidelines.
Do not post project code on help1001. For obvious reasons, this behaviour undermines the entire
assessment process: as such you will be liable for punishment under the University’s Policy on Academic
Conduct, even if the behaviour is unintentional.
Before you start a new topic, check first to see if your question has already been asked and answered in
an earlier topic. This will be the fastest way to get an answer!
When you do start a new topic, give it a meaningful subject. This will help all students to search and to
make use of information posted on the page. And please use method names, not TODO 12 or similar.
Feel free to post answers to other students’ questions. And don’t be afraid to rely on other students’

answers: we read everything on help1001 and we will correct anything inaccurate or incomplete that may
be posted from time to time.
Be civil. Speak to others as you would want them to speak to you. Remember that when you post
anonymously, this just means that your name is not displayed on the page; your identity is still recorded
on our systems. Poor behaviour will not be tolerated.
Do not post project code on help1001, or anywhere else online. This one is worth saying twice.
If you have a question of a personal nature, do not post to help1001: please email Anwarul or Caitlin instead.
The project will also be a big topic for discussion in the online lab sessions via ms-teams(online enrolled
students). This is fine of course, but again please be careful not to share code accidentally with other students.
Some things to look out for include the following.
Do not share your desktop or files in a ms-teams session.
Do not include code in any chat message.
Project Extension
An extension to the project is available by which you can earn extra marks in the assessment.
Up to 5 marks can be earned this way, which can replace marks lost in the main assessment. It is not
possible to get a mark greater than 87 for the project.
Late submissions will not be awarded any extension marks.
If you attempt the extension, submit in the normal way and email Anwarul before the deadline to let us
know what you have attempted. No extension marks will be awarded without such notification.
While you can get full marks in the project if you submit a correct program with no clarity issues, there are
many ways in which the game experience might be improved. Use whatever sources you find on the Internet
and your own imagination to come up with ideas for extending the player’s experience, and implement those
ideas to earn extra marks. Broad ideas include:
enhancing the game display;
using the mouse in more interesting ways;
reporting solution failures in more detail;
automatic help for the player;
an automatic solver for the game;
or whatever else you might think of;
Go for it! But please note the following:
1. do not change the existing functionality – the testing and marking classes will complain. Add
new functionality instead.
2. Do not edit other classes other than the ones you were asked to submit. You can only edit the Item,
Board, AIPlayer and GameViewer classes. Do not edit the SimpleCanvas or Piece classes. If you do
this, your extension will not be marked.

Department of Computer Science & Software Engineering