Contents
Task one: ............................................................................................................................................. 2 Task two: ......................................................................................................................................... 6
Task three: ........................................................................................................................................ 14
Task one:
Brief: Task one was to simulate a dice game with the user having the option to roll a 4 sided, 6 sided or 12 sided dice. The user should be able to repeat the process as many times as they would like and should be able to see what their dice has rolled. Also the numbers rolled had to be chosen at random.
Allows the user to choose which sided dice they would like to use.
When the user selects what dice they would like to roll it activates the switch of that particular dice. For example if I clicked roll on the 4 sided dice it will broadcast that the dice needs to be rolled and when it receives the broadcast it will roll and select a number 14 at random and will do the same with any other dice.
Code for the 4 sided dice.
Code for 6 sided dice.
Code for 12 sided dice.
When it receives the broadcast it rolls the dice chosen.
Picks a random costume which determines the number chosen at random. Tells you what number has been chosen depending on the costume outcome.
Glides vertically down and increases the size of the number rolled for the user to see clearly for all 3 dice.
Progression  Task one.
This program showed all of the numbers that could be rolled but rolled the name number all the time.
This added code also showed all the numbers that could be rolled but this time picked a random number from 14 on the 4 sided dice.
This is the same with the 6 and 12 sided dice.
After getting the program to a pick random number on the 4 sided dice I added in a bit more. I also added a function that moves the dice vertically down and enlarges it whilst telling the user what they rolled (as shown in the recordings).
Showing the numbers picked at random.
4 Sided Dice rolled 50 times
Dice number 1 2 3 4
6 Sided Dice rolled 50 times
Number of times rolled 10 15 11 14
Dice number 1 2 3 4 5 6
12 Sided Dice rolled 50 times
Number of times rolled 8 7 9 7 10 9
Dice number 1 2 3 4 5 6 7 8 9 10 11 12
Number of times rolled 4 5 3 4 5 6 2 3 4 5 3 6
Flowchart
Event occurred – Start Program
Is the Dice chosen the 4 sided dice?
Yes Dice rolls Output the number rolled End program
No
Is the Dice chosen the 6 sided dice?
Yes Dice rolls
Output the number rolled
End program
No
Is the Dice chosen the 12 sided dice?
Yes Dice rolls
Output the number rolled
End program
Success Criteria: The user can see the 4, 6 and 12 sided dice options. [Done] The user can choose which dice(s) they would like to roll. [Done] The program outputs the value on the dice chosen. [Done] The program lets the user roll which ever dice as many times as they like. [Done]  The program allows the dice to pick a random value and will repeat to pick random values each time dice(s) are rolled. [Done]
Evaluation: When I first looked at the task I decided to plan some solutions and start coding and working on the task. When I first started working on the task I reached a problem which was that when it was picking a random number for the different dices it always picked the same numbers. I then fixed this by getting each dice to pick random values every time the dices were rolled by the users which is what the task stated. After that I worked on the code a bit more and added a function that tells you which number was chosen and it said “you have rolled a __ “Number rolled and vertically moves the number down and increases the size to present the number chosen clearly.
Task two:
Brief: Task two was to determine the characters attributes which were skill and strength. At the start of the game a 4 sided dice and a 12 sided dice are thrown to determine the values of these attributes. The initial values of skill and strength had to be set to 10, the 12 sided dice would be divided by the 4 sided dice and if it is a decimal it would be rounded down to the nearest integer and then this value would be added to the initial value. 4 sided dice variable value.
12 sided dice variable value.
When the user clicks roll the broadcasts the message “roll dice” and when the 12 sided and 4 sided dice receive the broadcast the dices will roll.
Strength variable value Skill variable value
4 Sided dice code code
12 Sided dice code
When “Roll” is clicked the variables reset. Like in task one the dices pick a random number for each dice. When “roll” is clicked by the user it broadcasts “roll dice”. When “Roll dice” is received it rolls the 4 sided and 12 sided dice. It sets the variable “number#1” to the value rolled on the 4 sided dice and set the variable “number#2” to the value rolled on 12 sided dice. Changes the strength value as it divides the variable “Number#2” (the value on the 12 sided dice) by the variable “Number#1” (the value on the 4 sided dice) and rounds it down to the nearest whole number if the number is to a decimal point. It then adds the initial value which is 10 to the current strength value which was “Number#1” / “Number#2”.
If the value of the variable “Strength” is 10+ (10 or more) then broadcast “skill” which will determine the skill value. (The strength value will always be 10+ since the initial value is 10)
Strength variable value stays the same as the value has already been determined.
The Number variables are reset to zero so they are ready to be used again to determine the characters skill. Changes the skill value as it divides the variable “Number#2” (the value on the 12 sided dice) by the variable “Number#1” (the value on the 4 sided dice) and rounds it down to the nearest whole number if the number is to a decimal point. It then adds the initial value which is 10 to the current strength value which was “Number#1” / “Number#2”. (Just does the same as strength but except its skill this time)
Small delays to give the user time to see what’s going on.
Stops the program
Tells the user what attribute is being rolled.
Tells the user what attribute is being rolled.
Event occurred – Start Program
Display “Rolling to determine characters strength”.
12 sided dice rolled and 4 sided dice rolled.
Set Strength to value of 12 sided dice / value of 4 sided dice. Add 10 to the strength value (because initial value is 10)
NOTE: This will never occur because the initial value is 10 therefore it will always be 10 or more and will never come to a situation like this.
Is the value of Strength 10+ (10 or more?) Yes Display “Rolling to determine characters skill”.
No End program
Reset Dice values but keep strength value the same.
12 sided dice rolled and 4 sided dice rolled. Set Skill to value of 12 sided dice / value of 4 sided dice. Add 10 to the strength value (because initial value is 10)
End program
12 sided dice 10 1 7 12 sided dice 6 4 12
4 sided dice 2 1 3 4 sided dice 4 2 4
What’s happening? 10/2 = 5, 10 + 5 = 15 1/1 = 1, 10 + 1 =1 1 7/3 = 2 (rounded down), 10 + 2= 12 What’s happening? 6/4 = 1 (rounded down), 10 + 1 = 11 4/2 = 2, 10 + 2 12/4 = 3, 10 + 3 = 13
Strength 15 11 12 Skill 11 12 13
Variables used for task 2:
Number#1 – Data Type: Integer  The Variable Number#1 was used as it took the value from the 12 sided dice and became that value to be later used. Number#2 – Data Type: Integer  The Variable Number#2 was used as it took the value from the 4 sided dice and became that value to be later used.


Strength – Data Type: Integer – The Variable Strength is determined by the first values of the variable number#1 / the variable#2 added to the initial value which is 10. The number is then set to the variable strength and used to determine the value of the characters strength. Skill – Data Type: Integer – The Variable Skill is determined by the second set of values of the variable number#1 / the variable#2 added to the initial value which is 10. The number is then set to the variable strength and used to determine the value of the characters skill.

Progression  Task two. After seeing the task I planned possible solutions and ended up with this piece of code. The code was working fine but when the variables number#1 and number#2 got to the division part it produced decimal numbers so I had to adjust it. I adjusted it and changed it so that when it reached the division stage it did not end up with decimals points and rounded down to the nearest integer like the instructions of the task stated.
Problem
Correction
Success Criteria:  The program allows the user to roll the 12 sided and 6 sided dice and output random values rolled. [Done]  The program allows the value on the 12 sided dice to be divided to the value on the 4 sided dice. [Done]  The program rounds down any decimal numbers to the nearest integer (whole number). [Done]  The program adds the value of the 12 sided dice divided by the 4 sided dice to the initial value which is 10. [Done]
Evaluation: When I first looked at the task I decided to plan some solutions and start coding and working on the task. When I first started working on the task I reached a problem which was that when it got to the division stage it outputted decimal number. After seeing the problem I thought of ways to fix the problem and modified the code so that when it reached a decimal number it rounded down to the nearest integer.
Task three:
Brief: Task two was to make a game that would calculate the difference of your characters strength and the computers strength as well as your skill and the computers skill in which you inputted. It then should divide the differences of skill and strength by 5 and output the values in the skill and strength modifier. Then you roll the dices and the player with the highest dice would gain the values on the strength and skill modifiers onto their own strength and skill. However the person with the lowest dice would lose the value on the skill and strength modifier on their strength and skill. If the numbers rolled are the same then a message should appear saying the user to re roll the dice. If the user reaches a strength of zero then they loser, however if the computer reaches a strength of zero then they would win. Also the user must be able to input their inputs and the computer’s inputs and the dices must be 6 sided. Your strength and skill variables. Computer’s Strength and skill variables
Dice 1 variable which is the value of the dice.
Strength and Skill Modifier variables.
Dice 2 variables which is the value of the dice.
When the user clicks roll the broadcasts the message “start” and when the broadcast is received you fill in your inputs and the computer inputs. Also every time the person chooses to begin the program the values will reset.
Variables used for task 3:  Computer’s Skill – Data Type: Integer  The Variable Computer’s skill is determined by the value you input for the computer’s skill. Computer’s Strength  Data Type: Integer  The Variable Computer’s Strength is determined by the value you input for the computer’s Strength. Your Skill  Data Type: Integer  The Variable Your skill is determined by the value you input for the your skill. Your Strength  Data Type: Integer  The Variable your strength is determined by the value you input for the your strength. Dice 1  Data Type: Integer  The Variable Dice 1 displays the value for the first 6 sided dice. Dice 2  Data Type: Integer  The Variable Dice 2 displays the value for the second 6 sided dice. Skill modifier  Data Type: Integer  The Variable Skill modifier is determined by the difference of your skill and the computer’s skill divided by 5. Strength Modifier  Data Type: Integer  The Variable Strength modifier is determined by the difference of your skill and the computer’s Strength divided by 5.
Your Skill 10
10
50
Your Computer’s Computer’s What strength skill strength happens? 20 20 10 2010 = 10 / 5 = 2 (for both) 10 1 1 101=9/5 =1.8 = 1 (rounded down) 20 20 50 5020= 30 / 5 = 6 (for both)
Skill Modifier 2
Strength Modifier 2
1
1
6
6
Asks and allows the user to input their skill and strength as well as the computer’s skill and strength values Sets the input values the user entered to the assigned places
If the numbers are the same it will display a message telling you to re roll.
This part of the code rounds the values of the skill modifier and strength modifier down to the nearest integer like in the previous task. It also takes away the difference between your strength/skill with the computer’s strength/skill and will never reach a negative number as the code has been adjusted so that if it reaches a negative number it will convert into a positive. It will divide the difference and divide it by 5 as shown in the code and in the recording.
Event occurred – Start Program
Flowchart for task 3
Input your skill
Input your strength
Input Computer’s Strength
Input Computer’s Skill
Works out the difference of your strength and computer strength as well as your skill and computers skill
Divides the differences by 5 and puts the result values in the Strength and skill modifiers
Both dice rolls
Are the dice the same value?
Yes
Displays message telling the user to re roll the dices
No
No The player with the highest number rolled gets the value in the strength/skill modifiers added to their current strength/skill values Has your strength or the computer’s strength reached zero? Yes If Computer’s strength is zero display “you win” if your strength is zero display “you lose”.
End
Code for both 6 sided dice:
Almost the same code applied in task one and yet again picks the numbers at random.
If the computer’s dice is greater than the your dice it will subtract your strength/skill with the value on the modifier and will add the computer’s strength and skill with the value on the modifier. If the dice values are the same on Dice 1 and Dice 2 then it will broadcast a message and once received it will display a message as shown above If your dice is greater than the computer’s dice it will add your strength/skill with the value on the modifier and will subtract the computer’s strength and skill with the value on the modifier
If your strength or the computer’s strength = 0 then display you win/ you lose depending on outcome.
Progression of task 3:
Corrected
Problem
After seeing the task I planned possible solutions and ended up with this piece of code. The code was fine until I realised when you subtract the differences if the first number wasn’t larger than the second it would cause a negative number to occur which was problematic.
However I managed to fix this and this which meant if the first number wasn’t larger than the second number it would still positive and would not be problematic and did not affect the result in any way as shown in the video recordings of this task.
Success Criteria:  The user is aloud to input their strength and skill as well as the computer’s. [Done]  The program works out the difference of you skill and the computers skill and divides it by 5 and outputs this value into the skill modifier. [Done]  The program works out the difference of your strength and the computer’s strength and divides it by 5 and outputs this value into the strength modifier. [Done]  The program adds the skill and strength modifier to your skill and strength if the value on your dice is greater than the computers. It will also subtract the value on the modifiers to the computer’s skill and strength. [Done]  The program adds the computer’s skill and strength modifiers to the computers skill and strength if the computers dice is greater than yours. It will also subtract the value on the modifiers to your skill and strength. [Done]  The program allows your character to die/lose if your strength is zero and allows the computer to die/lose and let you win if the computer’s strength reaches zero. [Done]  The program asks you to re roll the dice if the values on your dice an the computers dice are the same. [Done]
Evaluation: When I first looked at the task I decided to plan some solutions
and start coding and working on the task. When I first started working on the task I reached a problem which was that if the first number was smaller than the second (for example your skill was larger than computers strength) the number would be negative and cause problems when being divided by 5 and added to the modifier. However I managed to fix this problem early on and the program was able to keep the numbers positive without having any affect on the values as seen in the video recordings.