Discipline of Computing

While the robot is in the process of moving, it is considered to occupy both its original
and new grid square. No other robot can move into either of those grid squares.
• If any robot moves into the fortress square, the game ends, and the player receives their
final score.
• The player can shoot robots by clicking on any single grid square. If a robot is occupying
that square (whether it is stationary or moving to/from it), that robot disappears from
the screen and is removed from the game.
The player cannot actually fire more than once per second. However, the player may queue
up firing commands by clicking on several squares in quick succession. Queued-up firing
commands will then be executed at one-second intervals, until there are no commands
left.
• Each time a robot is created or destroyed, or the player fires and misses, this should be
logged in an on-screen text area. (Don’t include other events in this log.)
The word “randomly” appears several times above. If you prefer, you can instead implement
some sort of pre-determined pattern or logic, as long as the full range of values is still in play.
2 Scoring
The player receives an increasing score as follows:
• The score begins at 0.
• For each second that passes (until the game ends), the score increases by 10 points.
• For each robot that the player successfully shoots, the score increases by 10+100 t
d
. Here,
d is the robot’s delay value (in milliseconds), as above, and t is the player’s time delay.
That is, t is the time (in milliseconds) elapsed between the player issuing the fire command (clicking on a square) and the fire command actually being executed.
(The 100 t
d
part is a bonus, since it’s naturally more difficult to hit a robot with a queuedup fire command, and more difficult still if the robot moves faster.)
The current score should be shown on the screen at all times.
3 Pre-Existing Code
There are pre-existing demo apps written in Java using Swing and JavaFX. It is recommended
that you choose one of them as the starting point for your application, although this is not
strictly required. JavaFX is slightly more modern than Swing, but the two demo apps are functionally identical.
Each demo app sets up a basic GUI layout, but also includes an …Arena class that displays a
grid on the screen, with hard-coded dimensions. It is not finished. The intention is for you to
modify this class according to your needs, but the basic logic regarding where things are drawn
on the screen is given to you.
Both demo apps use the Gradle build tool, which isn’t being assessed in this assignment, but is
still very useful for making things work (especially for JavaFX). To compile and run the code
Page 2 of 5
SEC Assignment 1 Semester 2, 2020
from the command line, simply type:
[[email protected]]$ ./gradlew run (On Linux/MacOS)
C:\…> gradlew run (On Windows)
Keep the directory structure intact. That is, all the source code should go inside the directory
src/main/java (although you may optionally create subdirectories within that to represent
Java packages, if you wish). If you change the name of App.java, you must change the reference
to it in the build.gradle file too.
The image file(s) for the robots (and a couple for the “fortress”) are in src/main/resources.
There are some included images, but you may substitute your own. You could replace robots
with zombies, pirates, etc. if you prefer. You can stick with a single image for all the “baddies”,
or select a random image each time.
If you prefer to use an IDE, you can. However, any difficulties that you run into as a result of
your IDE are your problem!
4 Threading Requirements
Technically speaking, this application could be made to work without multiple threads.
However, it is a requirement of this assessment that you do use multiple threads, and do so in
a sensible fashion, to prevent race conditions and deadlocks, and to preserve maintainability.
You are also required to make use of the following, for their intended purposes:
• A blocking queue.
• A thread pool.
• InterruptedException.
These are likely not the only threading constructs you will need to use, but the rest is up to you
to determine.
To help implement the timing requirements, it is recommended that you make use of:
• System.currentTimeMillis(), which returns a long integer: the number of milliseconds
elapsed since 1970. (Call this twice, and take the difference of results, to determine how
many milliseconds have elapsed between the two calls.)
• Thread.sleep(), which suspends the current thread for a specified number of milliseconds.
Alternatively, there are more advanced timing mechanisms available too if you prefer to investigate and use those.
5 Report
Prepare a report (3 pages or more) that addresses the following issues:
• Explain your design in regards to threading. In particular:
– Which classes are responsible for starting threads, and what are these threads used
for?
Page 3 of 5
SEC Assignment 1 Semester 2, 2020
– How do they communicate?
– How do they share resources (if they do at all) without incurring race conditions
or deadlocks?
– How do your threads end?
Your discussion must reflect your own specific design. There are no marks here for simply describing how threads and threading mechanisms work in general.
• What would be the best way (architecturally speaking) to transform this app into a cooperative multi-player game, where each player has their own separate fortress, and they
must work together to stop the robots.
Consider some plausible non-functional requirements for such a system, and say what
architectural decisions could help satisfy them.
6 Mark Allocation
This assignment will be marked out of 30.
You will receive marks for your code as follows:
(a) [4 marks] – Appropriate division of responsibilities among threads/tasks. You haven’t
missed obvious opportunities for multithreading. You don’t have too many threads doing
unnecessarily trivial tasks. All your threads and tasks contribute towards solving the
problem.
(b) [4 marks] – Appropriate use of a blocking queue and other thread communication mechanisms as needed. The blocking queue in particular must be an actual part of the solution
(not just something added on).
(c) [3 marks] – Appropriate use of a thread pool and other thread-creation logic (with same
proviso as above).
(d) [3 marks] – Appropriate use of threading mechanisms in general to prevent race conditions and deadlocks.
(e) [3 marks] – Your code follows best practice in terms of readability and maintainability.
In the event that your code does not compile or run (or does not correctly implement the requirements in sections 1–4), it will be broadly assumed that it does not meet the above marking
criteria. However, the marker may exercise discretion.
In regards to your report:
(f) [3 marks] – Your actual design is thoroughly explained.
(g) [5 marks] – You convincingly identify a range of relevant issues that would need to be
solved, in order for a multi-player version of the system to be created.
(h) [5 marks] – Your convincingly explain what architectural decisions could be made to
solve the issues identified. Focus on the relevance of these decisions to the problem at
hand. Do not simply describe general types of software architecture.
Page 4 of 5
SEC Assignment 1 Semester 2, 2020
7 Submission
Submit your assignment electronically, via Blackboard, before the deadline. To submit, do the
following:
(a) Fill out and sign a declaration of originality. A photo, scan or electronically-filled out
form is fine. Whatever you do, ensure the form is complete and readable! Place it (as a
.pdf, .jpg or .png) inside your project directory.
(b) Zip up your entire project directory as-is (as a .zip or .tar.gz file). Leave nothing out.
(c) Submit your zip/tar.gz file to the assignment area on Blackboard.
(d) Re-download, open, and run your submitted work to ensure it has been submitted correctly.
You are responsible for ensuring that your submission is correct and not corrupted. You may
make multiple submissions, but only your newest submission will be marked. The late submission policy (see the Unit Outline) will be strictly enforced.
Please note:
• DO NOT use WinRar (or the .rar format in general).
• DO NOT have nested zip/tar.gz files. One is enough!
• DO NOT try to email your submission as an attachment. Curtin’s email filters are configured to silently discard emails with potentially executable attachments.
In an emergency, if you cannot upload your work to Blackboard, please instead upload it to
Google Drive, or a private Github repository, or another online service that preserves immutable
timestamps and is not publicly accessible.
8 Academic Integrity
Please see the Coding and Academic Integrity Guidelines (available alongside this specification on
Blackboard).
In summary, this is an assessable task. If you use someone else’s work or assistance to help
complete part of the assignment, where it’s intended that you complete it yourself, you will
have compromised the assessment. You will not receive marks for any parts of your submission
that are not your own original work. Further, if you do not reference any external sources that you
use, you are committing plagiarism and/or collusion, and penalties for academic misconduct
may apply.
Curtin also provides general advice on academic integrity at
http://academicintegrity.curtin.edu.au/.
The unit coordinator may require you to provide an oral justification of, or to answer questions
about, any piece of written work submitted in this unit. Your response(s) may be referred to
as evidence in an academic misconduct inquiry.

Sample Solution

ACED ESSAYS