You are on page 1of 15

UNIVERSITY OF MALAYA

BACHELOR OF COMPUTER SCIENCE / BACHELOR OF INFORMATION TECHNOLOGY


ACADEMIC SESSION 2018/2019: SEMESTER I

WIX1002 : FUNDAMENTALS OF PROGRAMMING

ASSIGNMENT

A. Problem specification
Your company, a regional software developer with 355 staffs, has received 4 new projects this
month: two on-line games, and a queuing system for a local hospital. All three of the projects
are equally important, with certain level of technical difficulties and challenges. You have been
instructed by the CEO to lead a team of 4-5 members, to handle one of the project. You have
been given 6 weeks to complete the project and prepare a demo for the board of directors. The
descriptions of the three projects are enclosed as appendices. You will be assigned one of
these projects once you have formed the team.

B. Group formation
1. Form a group of 4-5 members to do the project.
2. Every group member must contribute to the project, including certain amount of coding.
The role played by and contribution of each member to the project must be included in
the managerial report.

C. Submission
1. A technical report explaining the assigned task, the requirements of the task, the
approach taken to solve the task, a detail description of your solution (includes the flow-
chart, modules, etc.), sample snapshot of your program output.
2. A managerial report explaining the formation of the group, role and assigned work for
each of the members, the project timeline, the problems faced in accomplishing this
assignment and your solutions, and other issues arise.
3. The complete source code.

D. Important dates:
1. Submission: (week 13th) 12:00pm on Friday, 14th December 2018
2. Demo: (week 14th) during lab

1
E. Marking scheme: (15 marks)
1. Source code/Program. (12 marks)
a. Meeting the basic task requirements, i.e. identify the requirements of the task
and produce a workable solution – 8 marks
b. Extra features/functionalities that are not included in the task specification – 4
marks.
2. Report (3 marks)

2
Appendix A - Pokemon World Simulator
A. Introduction:
Have you ever dreamt of involving in the life of Pokemon World? How about creating your own
Pokemon World? This is where your journey begins. Now, you are the inventor of your own
virtual world: Rules, creatures, cities and even civilizations.
*Find your friends for help if you don’t know what is Pokemon or how to play the game.

B. Problem Statement:
You are required to make a pokemon 1 vs 1 combat system. Before start the combat, user
needs to choose to take a pokemon, then the opponent (bot) takes a pokemon. This process is
repeated until both have 3 pokemon. After that, the battle will start. User must be able to
choose any skill they wish to attack enemy.
The attack order is speed-based (Calculated based on Pokemon Speed, pokemon which
reaches accumulated value of 100 will attack). For better understandings, refer to the
example below:
Pokemon A speed: 40
Pokemon B speed: 50
Speed accumulator for Pokemon A: 0
Speed accumulator for Pokemon B: 0

First loop:
Speed accumulator for Pokemon A: 0 + 40 = 40
Speed accumulator for Pokemon B: 0 + 50 = 50
No pokemon will attack

Second loop:
Speed accumulator for Pokemon A: 40 + 40 = 80
Speed accumulator for Pokemon B: 50 + 50 = 100 - 100 = 0
Pokemon B will attack (Speed accumulator for Pokemon B minus 100 because of
attacking)

Third loop:
Speed accumulator for Pokemon A: 80 + 40 = 120 - 100 = 20
Speed accumulator for Pokemon B: 0 + 50 = 50
Pokemon A will attack (Speed accumulator for Pokemon A minus 100 because of
attacking)

3
It is totally possible for a pokemon to attack two times in a row. The speed accumulators will not
be reset for any circumstances. User must be given choice to switch pokemon anytime they
want, and previous Pokemon’s health points are retained. Opponent, on the other hand, casts
skills randomly. Battle ends when all three pokemons’ health points reach 0. Every move during
combat must be clearly displayed.

Here is the formula for combat system (Must be strictly adhered):


Damage = (((Pokemon attack * Skill’s power
/ Opponent’s pokemon defense) / 20) + 2)
* Damage Multiplier
The Damage Multiplier is the skill type advantage or disadvantage when attack other pokemon,
for example, if fire type move hits a grass pokemon, it will double the damage, if fire type move
hits a water pokemon, the damage will be halved. If the move type is same as pokemon type or
either move type or pokemon type is normal type, the damage will remain the same.

Skill accuracy: There are chances of missing attacks due to accuracy. For example, a skill with
skill accuracy of 70% will have 30% of missing attacks. For sample input of skill accuracy can
refer to the sample input section.
The program repeats until user prompts to exit.

4
C. Sample Input:
You are given a list of pokemons that store in the text file - “pokemon.txt”. You have to read the
file to get the 12 pokemon (you are free to increase the amount of pokemon yourself, and even
modify the pokemon stats) into the program:

5
D. Sample Output:

This is some sample outputs that might guide you through the way. However, you are free to do
any modifications for more detailed visualizations of the whole combat.

6
E. Some generous helps for you in case you need it:

Want to clear the screen of command prompt? Use this method:

public static void clearScreen() {


try {
new ProcessBuilder("cmd", "/c",
"cls").inheritIO().start().waitFor();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException ex) {
Logger.getLogger(Main.class
.getName()).log(Level.SEVERE, null, ex);
}
}

Or, if you want to write text on specific part of command prompt:

private static void print(String text, int row, int col) {


char escCode = 0x1B;
System.out.print(String.format("%c[%d;%df", escCode, row, col));
System.out.println(text);
}
}

7
F. Crazy ideas

There are some ideas for you to make your application greater, need not to follow all, but you
are always welcomed to try your limitations! If you have other ideas, just do it!

1. Imaginations are unlimited, I challenge you to change the gameplay of pokemon


simulator and make it more unique, in your own way!
2. Build a map, and let our characters move as if they are living!
3. Graphical user interface, perhaps?
4. Make an administration system to add, remove, modify pokemons and their status,
sounds cool, isn’t it?
5. Two big things: trading and inventory system.
6. I have heard that pokemons are categorized according to elements, and each element
has its own strengths and weaknesses? :)
7. Store the records for each fight, and display it whenever we want to, programmers
definitely love to play with data.
8. Try to make some sounds, or even animations so that we will not get bored.
9. We would like to fight bots, but please make it clever if you can, and justify how you
achieve that.
10. Player versus player combat system.

8
Appendix B - Maze Runner

A. Introduction:
Johnny, a renowned Maze Runner is experienced in hunting for valuables. However, during his
previous expedition, he was attacked by the scary Some Tribe in Some Island. The moment
when he woke up, it is in the middle of a dark scary night. He has no idea where he is.

Judging from his intuition, Johnny believes that he is being trapped in the famous GG Maze of
Some Island. Johnny needs to escape Some Island as soon as possible but he needs to collect
all the valuables that he has lost from GG Maze.
Can you help him?

B. Requirements:
You are required to write a simple game to simulate Johnny’s current situation.
The (minimum) specifications of the game are as follows:
1. You will need to generate a maze of size 20 x 20.
2. The maze will always have an exit, “E”, to escape the maze.
3. You must display whole maze, other than what is visible by Johnny (2 units), all must be
blacked out with “#”. (Common sense: Johnny cannot see through walls)
4. Johnny should be able to move in 4 directions, namely up, down, left, right in the maze
depending on whether there are any obstacles or not.
5. The lost items/ valuables should be randomly scattered around the maze, represented
by “@”.
6. If Johnny leaves the maze without all the lost items, Johnny is considered a disgrace to
the Maze Runner’s community.

9
C. Input:
The game is a turn-based game, you should take in a direction input every time you request
input from user and update the frame after the input.

D. Output:

# # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # #
# # # # # # # # # | | # # # # # # # #
# # # # # # # # --- | | --- # # # # # # #
# # # # # # # # @ J # # # # # # #
# # # # # # # # --- | | --- # # # # # # #
# # # # # # # # # | | # # # # # # # #
# # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # #

Enter your next move (W, A, S, D): A

E. Crazy ideas (Bonus Marks!!!)


1. An algorithm to generate the N x N maze depending on user input for size (N >= 20)
2. Johnny has a health bar (HP)
3. Johnny can collect weapons/ bonus items (e.g. lantern – to increase his visibility to 4
units)
4. Some Tribes are scattered around in GG Maze
5. Johnny can decide whether to fight the Some Tribes, or suffer from an attack and run
(with some loss of HP)
6. Graphical User Interface
7. AI?

10
Appendix C - Mastermind

A. Introduction:
Mastermind is a code-breaking board game. There are two sides in this game, namely the
codemaker and the codebreaker. The codemaker chooses a pattern of four colour code.
The chosen colour codes are not known to the codebreaker. The codebreaker will try to
guess the pattern, in both order and colour within a certain amount of turns. Once the
codebreaker made a guess, the codemaker will provide feedback by showing zero to four
black or white colour code. A black colour for each guess which is correct in both colour and
position while a white colour indicates of a correct colour code but placed in the wrong
position. If there are duplicate colours in the guess, they cannot all be shown by the
codebreaker unless they correspond to the same number of duplicate colours in the hidden
code. For example, if the hidden code is green-green-blue-blue and the codebreaker
guesses green-green-green-blue, then the codemaker will show 3 black colour code, two for
the two correct green, and one for the correct blue, nothing is shown for the third green in
the guess as there is no 3 green in the hidden code. The game continues until either the
codebreaker guesses correctly (codebreaker wins) or a certain amount of guesses are
made (codebreaker loses)

11
B. Requirements:
- A codemaker:
1. The codemaker should let player choose the number of colour code (two to
eight), and the total number of guesses allowed.
2. A function to generate the colour codes randomly.
3. A function to provide feedback to the player’s guesses.
4. A function to restart the game.
5. A timer that times how long the player took to complete the game.
6. Calculate scores of each player.

- Display screen:
1. There are two column of data that should be displayed on the display screen
which is the history of guesses made by the player, and also the corresponding
feedback.
2. The display screen should display a fixed number of rows (number of guesses
allowed)
3. The first guess should be displayed at the most bottom row.

- Scoreboard:
1. Record a list of top ten high scores with the player’s name.
2. Scores are calculated by using the formula below:

where n =
number of
guesses, t =
total time taken
and d = number of colour codes.
3. The scoreboard should be sorted by having the highest score on top.
4. The scores should be stored as text file and on each run, the text file will be read
to get the list of high scores.

Your team has to write a program to simulate the mastermind game, i.e. showing all of the
functionalities described above.

12
C. Extra features:
o GUI
o Logging, i.e. log every player’s guesses and save the results to a text file.
o Audio, i.e. play audio on each turn or when player wins.
o Allow player to give up and reveal the hidden code.
o Play as the codemaker against a programmed computer as the codebreaker.
Maybe? (Think of an algorithm to solve the game)
o Turn it into a two players game, where both players compete to solve the same
hidden code faster. Both boards are visible to each player.
o Royale Mastermind: Instead of just plain colour code, the code now consists of
both colour and shape. The player will have to correctly guess both colour and
shape of the hidden code.

o Your idea?

13
Appendix D - Dynamic RPG Map Generation

A. Description
Before Fortnite, Battlefield and PUBG rise to glory, there exist a special genre of games known
as Role Playing Game (RPG). Before 3D graphics were common, 2D RPG games such as Final
Fantasy, Zelda and even Pokemon were every child’s favorite. However, there is also a special
category of games in RPG, known as random dungeon RPG. In this assignment, your job is to
develop a system to generate a simple map for RPG.

B. Basic Requirements:
1. The map should be at least 10 x 10 large.
2. Player can move around the map (with w/a/s/d or any other method)
3. The map should consist of different terrains (water surface, grass surface, desert, etc).
4. NPC and enemy should spawn on the map as well.
5. Enemy should spawn far from the player.
6. Player should be able to communicate and interact with monster or NPC.
7. Simple combat system between player and enemy (suggestion: random number
generator)

C. Extra features:
1. Dynamic map size (minimum 10 x 10)
2. Enemy can move on their own as well movement.
3. Shop for player to interact with and buy weapons/armors.
4. Different kinds of enemies (weak to strong, weak to different weapons).
5. Level system for player and enemy.
6. Graphic User Interface
7. X Factor

14
D. Example map
- - - - - - - - - - - -
| ; . ` ’ Y “ . ’ = = |
| ` ‘ ` ’ ; . ` “ = = |
| “ . ; ’ ; ‘ , ’ ; “ |
| ‘ . ` ’ , . ` ; , , |
| ; ; ` ; @ . ; ’ . ` |
| ; . ` ’ ; . ` ’ ; . |
| * * * * ‘ ; ` ’ . ` |
| * * * ` . . X ’ , ; |
| * * * * ` . ` ; . ` |
| ; . ` ; “ . ; ’ . , |
- - - - - - - - - - - -
@ - player
Y - enemy
X - NPC
; - grass area
‘ - grass area
. - grass area
, - grass area
` - grass area
“ - grass area
= - desert
* - water surface

15

You might also like