a453 controlled assessment

25
A453 Controlled Assessment Contents Task one:........................................................ 2 Task two:.................................................... 4 Task three:...................................................... 6

Upload: ibrahimelakkad

Post on 28-Oct-2014

2.089 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A453 Controlled Assessment

A453 Controlled Assessment

ContentsTask one:...........................................................................................................................................2

Task two:........................................................................................................................................ 4

Task three:.........................................................................................................................................6

Page 2: A453 Controlled Assessment

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.

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 1-4 at random and will do the same with any other dice.

Allows the user to choose which sided dice they would like to use.

Page 3: A453 Controlled Assessment

Code for the 4 sided dice.

Code for 6 sided dice.

Code for 12 sided dice.

Picks a random costume which determines the number chosen at

Tells you what number has been chosen depending on the costume outcome.

When it receives the broadcast it rolls the dice chosen.

Glides vertically down and increases the size of the number rolled for the user to see clearly for all 3 dice.

Page 4: A453 Controlled Assessment

This added code also showed all the numbers that could be rolled but this time picked a random number from 1-4 on the 4 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).

Progression - Task one.

This is the same with the 6 and 12 sided dice.

Page 5: A453 Controlled Assessment

Showing the numbers picked at random.

Dice number Number of times rolled1 102 153 114 14

Dice number Number of times rolled1 82 73 94 75 106 9

Dice number Number of times rolled1 42 53 34 45 56 67 28 39 410 511 312 6

4 Sided Dice rolled 50 times

6 Sided Dice rolled 50 times

12 Sided Dice rolled 50 times

Page 6: A453 Controlled Assessment

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]

Is the Dice chosen the 4 sided dice?

Is the Dice chosen the 6 sided dice?

Is the Dice chosen the 12

sided dice?

Yes

Yes

Yes

No

No

Dice rolls

Dice rolls

Dice rolls

Output the number rolled

Output the number rolled

Output the number rolled

Flowchart

End program

End program

End program

Event occurred – Start Program

Page 7: A453 Controlled Assessment

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.

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

Skill variable Strength variable value

12 sided dice variable value.

4 sided dice variable value.

Page 8: A453 Controlled Assessment

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.

Like in task one the dices pick a random number for each dice.

When “Roll” is clicked the variables reset.

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)

4 Sided dice code code

12 Sided dice code

Page 9: A453 Controlled Assessment

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

Stops the program

Small delays to give the user time to see what’s going on.

Page 10: A453 Controlled Assessment

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)

Display “Rolling to determine characters skill”.

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)

Is the value of Strength 10+ (10 or more?)

No

Yes

End program

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.

End program

Page 11: A453 Controlled Assessment

12 sided dice 4 sided dice What’s happening? Strength10 2 10/2 = 5, 10 + 5 = 15 151 1 1/1 = 1, 10 + 1 =1 1 117 3 7/3 = 2 (rounded down), 10 + 2= 12 12

12 sided dice 4 sided dice What’s happening? Skill6 4 6/4 = 1 (rounded down), 10 + 1 = 11 114 2 4/2 = 2, 10 + 2 12

12 4 12/4 = 3, 10 + 3 = 13 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

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.

Page 12: A453 Controlled Assessment

Problem Correction

Page 13: A453 Controlled Assessment

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.

Page 14: A453 Controlled Assessment

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.

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

Dice 1 variable which is the value of the dice.

Dice 2 variables which is the value of the dice.Strength and Skill

Modifier variables.

Computer’s Strength and skill Your strength and skill variables.

Page 15: A453 Controlled Assessment

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

Your strength

Computer’s skill

Computer’sstrength

What happens?

Skill Modifier

Strength Modifier

10 20 20 10 20-10 = 10 / 5 = 2 (for both)

2 2

10 10 1 1 101=9/5 =1.8 = 1 (rounded down)

1 1

50 20 20 50 50-20= 30 / 5 = 6 (for both)

6 6

Page 16: A453 Controlled Assessment

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

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.

If the numbers are the same it will display a message telling you to re roll.

Page 17: A453 Controlled Assessment

Event occurred – Start Program

Input your skill

Input your strength

Input Computer’s Skill

Input Computer’s Strength

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?

Displays message telling the user to re roll the dices

Yes

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?

No

If Computer’s strength is zero display “you win” if your strength is zero display “you lose”.

Yes

Flowchart for task 3

Page 18: A453 Controlled Assessment

Code for both 6 sided dice:

End

Almost the same code applied in task one and yet again picks the numbers at random.

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 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 your strength or the computer’s strength = 0 then display you win/ you lose depending on

Page 19: A453 Controlled Assessment

Progression of task 3:

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.

If your strength or the computer’s strength = 0 then display you win/ you lose depending on

Problem

Corrected

Page 20: A453 Controlled Assessment

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]

Page 21: A453 Controlled Assessment

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.