CS计算机代考程序代写 Java gui javaFx algorithm CS-230 Software Engineering, Functional Specification (2021/2022)

CS-230 Software Engineering, Functional Specification (2021/2022)

CS-230 Software Engineering

Functional Specification (2021/2022)

Liam O’Reilly

2

1 Introduction

You have been tasked with creating a digital version of
the 1996 Rats! game by Sean O’Connor. This is a game
of strategy, quick response … and of course a little luck!

There are various YouTube videos that show gameplay
of the original game. Some of these are:

• https://youtu.be/YnO406cOVmM

• https://youtu.be/VFvpPHN8TXo

There also seems to be current versions of the game at
http://www.windowsgames.co.uk/rats.html. Please
note I am not endorsing this site or guaranteeing that
the software available there is free from malware. You
do not need to download the software.

The game’s rules are detailed in this document. They
are not too complex, but not too simple either. Various
design decisions have been taken to keep the complex-
ity at a reasonable level and deviate from the original.
The rules specified here are a little loose. If they specify
something then it must be followed, but otherwise you
have creative freedom.

It is up to you to design the classes, algorithms and GUI
involved in the development of this game.

The gameplay specified in this document mostly align
to the original game, but do differ in places and func-

tionality.

2 Game Title and Theme

You are free to come up with the title and theme of the
game. You may stick with the theme of rats or you may
choose your own by putting some thought into this and
making something unique and exciting!

This document describes the type of tiles and icons used
in the game. You may draw them to align them to your
theme. For example, you could create a game around
robots, dinosaurs, or whatever you like. The items (see
Section 3.3) can also be substituted according to your
theme as long as they behave as described in this doc-
ument.

The graphics used in this document are intentionally
simple and plain (much plainer than the original game).
You can and should produce nicer graphics if you are
able to. Even simple image files, when tiled, can look
very nice.

3 Overall Idea, Components, and
Gameplay

The game is played on a level made up of square tiles
that form a rectangular area of paths which rats travel

Page 1 of 5

http://www.windowsgames.co.uk/rats.html

CS-230 Software Engineering, Functional Specification (2021/2022)

along. Your job is to eradicate all the rats before they
breed and overrun you.

Many of the details below leave certain quantities and
durations open. The level files will specify these value
(see Section 5).

3.1 Tiles

The tiles that make up the level are all square and the
same size. They are:

• Grass – This acts as a wall.

• Path – Rats move around on the paths.

• Tunnel – Rats can also move though tunnels where
you cannot see them.

These form a rectangular level. Below we have a level
which is 3 tiles high by 8 tiles wide. The top and bot-
tom row are all grass tiles, while the middle is 1 grass
tile, 3 path tiles, 2 tunnel tiles, 1 path tile and finally a
grass tile.

The paths and tunnels allow the rats to move around.
While rats are in tunnels you cannot see them but the
rats behave as they do on paths. The grass form walls
that block the rats and also form the edge of the level.

3.2 Rats

The rats move around the paths and the tunnels. The
rats come in a few forms:

• Adult Male rats – These adult males mate with
the adult female rats.

• Adult Female rats – These adult females mate
with the adult male rats and give birth to baby
rats.

• Baby rats – These are young rats that are not fully
developed. Each is either male or female, but you
cannot tell until they develop. They also move
quicker than adult rats.

• Death rats – These rats are placed by you and kill
the other rats they encounter.

At the start of each level all the rats begin as baby rats.
Each baby rat already has a sex but due to their grey
fur, one is not able to tell what it is. Baby rats quickly
develop into adult rats. As an adult rat they move a
little slower.

All rats move in the following way. They move forward
in the direction they are travelling until they hit a cor-
ner, junction, or dead end. In the case of a corner, the
rat simply follows the path. In the case of a junction
the rat will take one of the available direction (except
for the one that it entered on). In the case of a dead
end the rat will turn around.

Rats can move on to and occupy the same tiles as other
rats. Any time a male rat and female rat (that is not
pregnant) find themselves on the same tile they mate.
This mating takes a few seconds where both rats remain
on the same tile. After this both rats continue moving
in the directions they were going. The female rat is
now pregnant and will give birth shortly. After a few
seconds the female rat starts giving birth, as she moves
baby rats are produced, one at a time, in her wake. The
female rats will give birth to multiple baby rats during
each pregnancy.

3.3 Items

You have different items in your inventory that you can
use to help win each level. You win each level by killing
all the rats. You may hold up to 4 of each type of item
in your inventory. You use an items by placing it on a
path on the level (not a tunnel nor grass). Each time
you use an item it is removed from your inventory.

The available items are:

• Bombs

• Gas

• Sterilisation

• Poison

• Male Sex Change

• Female Sex Change

• No Entry Signs

• Death Rats

Page 2 of 5

CS-230 Software Engineering, Functional Specification (2021/2022)

Rats can move through all items except for no entry
signs.

Items will be placed into your inventory seemingly ran-
domly. However, the insertion of items will be controlled
by values in the current level (see Section 5).

3.3.1 Bombs

Once placed, a bomb will count down from 4 in 1 sec-
ond increments. Once the bomb reaches zero a power-
ful explosion will extend vertically and horizontally (not
diagonally) until it reaches grass in all directions (the
explosion passes through tunnels). The grass prevents
the explosion from continuing in a given direction. The
explosion will kill any rats on these tiles and will also
destroy any other items currently placed on these tiles.
Each bomb should display a count down: 4, 3, 2, 1.

3.3.2 Gas

Once placed, gas will slowly expand and occupy neigh-
bouring tiles. Gas can travel through tunnels, but this
cannot be seen. Gas will kill rats that stay/travel in the
gas too long. As baby rats travel faster than adult rats,
they can travel through more gas before it kills them.

After a few seconds the gas stops expanding and starts
to dissipate until it is no longer present.

Exactly how this gas expands and dissipates is left to
you as an open design decision.

3.3.3 Sterilisation

Once placed, the sterilisation item will make all rats
within a small radius sterile. It will remain active for
a few seconds. The exact amount of time and radius
is left as an open design decision (but probably a ra-
dius of 2 tiles and being active for 3 seconds would be
reasonable).

A sterile baby rat will develop into a sterile adult rat.
A sterile adult rat will not mate with other rats.

3.3.4 Poison

Once placed, poison will remain on the path until a rat
runs into it. Once a rat runs into it the rat is killed and
the poison is used up and removed from the path.

3.3.5 Male Sex Change

Once placed, a male sex change item will remain on the
path until a rat runs into it. Once a rat runs into it the
rat becomes male and the item is used up and removed
from the path (if the rat is male, the item is still used
up and removed).

3.3.6 Female Sex Change

Once placed, a female sex change item will remain on
the path until a rat runs into it. Once a rat runs into
it the rat becomes female and the item is used up and
removed from the path (if the rat is female, the item is
still used up and removed).

3.3.7 No Entry Signs

Once placed, a no entry sign prevents rats from pass-
ing. If a rat hits a no entry sign then it behaves like
grass with one exception. The no entry sign will be
slightly damaged and after being hit multiple times will
disappear. The exact amount of times is left as an open
design decision (but probably 5 times would be reason-
able). The appearance of the no entry sign should reflect
how damaged it is. This could be done by using different
images where the no entry sign visibly degrades (e.g.,
cracks) or could be as simple as a numerical counter
displayed on top of the no entry sign.

3.3.8 Death Rats

Once placed a death rat will remain stationary for a
second or two. After which, it will move just like other
adult rats. A death rat will kill the first 5 rats it en-
counters, after which, it dies.

3.4 Winning and Losing

You win each level by killing all the rats.

You lose if the rats reach a certain population as speci-
fied in the level (see Section 5).

There should be a visual indicator that shows how close
to winning or losing you are (i.e., this indicator shows
the current population of the rats and how many are of
each sex).

Page 3 of 5

CS-230 Software Engineering, Functional Specification (2021/2022)

3.5 Scoring

You get 10 points per rat you kill (this includes baby
rats that have not been born and are still developing
within their mother). You get additional bonus points
for finishing the level before the expected time for the
level (see Section 5): 1 point per unused second.

4 Simplifications from the Origi-
nal Game

The gameplay specified in this document mostly align
to the original game, but do differ in places and func-
tionality. Here is a non-exhaustive list of some of the
more major aspects:

• While the game should be designed and imple-
mented to have good looking graphics, it does not
need to have smooth animation. Thus, a jumpy
form of animation is fine. Of course, if you really
want to you can implement a smooth style – but
this will be much much more difficult.

• Rats occupy one tile at a time (as opposed to be-
ing partway between tiles as in the original game).

• Rats move by “jumping”/“teleporting” from one
tile to another (as opposed to smooth animation
in the original).

• Explosions from bombs, activation of serialisation,
etc. need not have nice animations – they can have
no animations at all.

• Scrolling the board is not necessary (you can cre-
ate the levels so that they fit in the window.

5 Levels

The game will comprise of multiple levels. Upon com-
pleting a level the next level will be unlocked. Your
player profile will keep track of the maximum level you
have unlocked (see Section 6). You can replay all un-
locked levels.

Each level is stored in its own file. It is up to you how
you design and structure these files. However, they must
be simple ASCII based files.

Each level must store the following information (not
necessarily in this particular order):

• Size of the level (width and height) – The level
need not be square.

• The type of each tile (grass, path, or tunnel).

• The starting locations of all baby rats and their
sex (all rats start off as babies).

• The population of rats (i.e., number) which will
cause the player to lose the level.

• The number of seconds that the player is expected
to complete the level in (see Section 3.5).

• Data for controlling how often you receive each
type of item in your inventory.

A starting point of your design might be as follows:

1 15,7
2 GGGGGGGGGGGGGGG
3 GPPPTTPPPTTPPPG
4 GGGPGGGGPGGPGPG
5 GPPPGGPPPGGPGPG
6 GPGGGGGGPGGPGPG
7 GPPPTTPPPTTPPPG
8 GGGGGGGGGGGGGGG

The above specifies the tiles of the level shown at the
very start of this document (G for grass, P for path, T
for tunnel). The first two numbers specify the width
and height of the level (which will make parsing the file
easier).

The rest of the data such as the starting locations of all
baby rats and their sex could follow.

There are many ways to design this.

6 Player Profiles

The application should support player profiles. Player
profiles are used to record game stats for different play-
ers. Player profiles can be created and deleted via ap-
propriate menu items or buttons within the application.

Each player profile:

• has a player name.

• keeps track of the maximum level that has been
unlocked.

7 High Score Tables

The application keeps track of a high score table per
level and also allows these to be displayed (per level).
Each time a player completes a level, their profile name
is recorded on the high score table for that level along
with their score. Only the top 10 scores are kept (if a
player scores less than all the top 10 for that level then
they do not get added to the high score table).

8 Data Persistence

The player profile data is persisted across runs of the
application. That is, if the user quits the application,
then upon reopening of the application, the data is not
lost.

Page 4 of 5

CS-230 Software Engineering, Functional Specification (2021/2022)

9 Save/Load Games in Progress

The user shall have the ability to save an ongoing game.
This will save the current game state to a file. The user
can later load the saved game and resume play. All tiles,
rats, items in play, and items in the inventory shall be in
the same state as they were when the game was saved.

10 Message of the Day

A special Message of the Day (which might change much
more frequently than once a day) should be displayed in
the app. This message must be displayed in full without
modifying any of the characters.

You will need to use a special API (developed for CS-
230) to retrieve the message and display it. You should
retrieve this message each time the game is launched.

The URL for this service is: http://cswebcat.swan.
ac.uk

Note: This will involve own research on how to issue
HTTP requests, handle HTTP responses, and read the
documentation of the Message of the Day API (found
by visiting the above URL).

11 Extra Features

This section is not part of A1, but it will be part
of A2. It will be helpful for you to plan for ex-
tensibility and hence know about this section.

To achieve top marks in A2, you will need to be creative.
At a minimum, all the functionality of the Functional
Specification should be completed to a high standard.
All features should adhere strictly to the specification.
You need to get all this working well in order to get a
low First Class mark (in A2). In order to get higher
marks, you are required to extend the implementation
in novel ways. All extensions that do not violate the
specification will be considered. Substantial extensions
to the software, extra reading and learning, will be re-
quired to achieve a high First Class mark (in A2).

12 Forbidden Features

There are forbidden features which you must not
design nor implement. These features are re-
served for assessment of CS-235.

Do not design nor implement the following fea-
tures for CS-230:

• A level editor that allows users to create and de-
sign their own custom levels via a nice editor.

• Allowing multiple difficulties per level (where for
example, the same level at a higher difficulty
would have more starting rats).

13 Libraries and Frameworks

You must program this game in Java using JavaFX. It
is strongly recommended to use JavaFX’s Canvas class
to draw the game.

You may use any classes and packages that are part of
the standard Java SDK.

You may not use any other libraries or frameworks with-
out first seeking approval. Please use the forums to ask
such questions.

Game frameworks will not be allowed.

Page 5 of 5

http://cswebcat.swan.ac.uk
http://cswebcat.swan.ac.uk

Introduction
Game Title and Theme
Overall Idea, Components, and Gameplay
Tiles
Rats
Items
Bombs
Gas
Sterilisation
Poison
Male Sex Change
Female Sex Change
No Entry Signs
Death Rats

Winning and Losing
Scoring

Simplifications from the Original Game
Levels
Player Profiles
High Score Tables
Data Persistence
Save/Load Games in Progress
Message of the Day
Extra Features
Forbidden Features
Libraries and Frameworks