The Dice Game

The dice simulator and subsequent dice playing game was a Pre-2015 GCSE CS Controlled Assessment task from OCR.   It is probably their most exciting coursework ever and is here so everyone gets a chance.  It also contains hints on completing the CA well.

Task 1 Simulating a dice

A game uses dice with 4, 6 and 12 sides to determine various outcomes.

Design, code and test a program that will simulate throwing dice with these numbers of sides.

The user should be able to input which dice is being thrown, eg 4, 6 or 12.

The program should output the dice chosen and the score, for example ‘6 sided dice thrown, score 4’

The user should be able to repeat this process as many times as required.

Initial Statement.

Create program that simulates a roll of a 4, 6 or 12 sided dice. The user will pick what dice is to be thrown the program will then output the result of the throw. This will be able to be done as many time as required.

Success Criteria

  • The system should display a choice of a 4, 6 or 12 die.
  • The user will then be able to choose which die that will be rolled
  • The system will then ‘roll’ the chosen die
  • The output of die chosen and the die roll will then be displayed
  • The process will then be able to be repeated

Task 2 Determining a character’s attributes

When determining certain characteristics of a game character the numbers on a combination of dice are used to calculate certain attributes.

Two of these attributes are strength and skill.

At the start of the game, when the characters are created, a 4 sided dice and a 12 sided dice are thrown to determine values for each of these attributes using the following method for each character:

  • Each attribute is initially set to 10.
  • The score on the 12 sided dice is divided by the score on the 4 sided dice and rounded down.
  • This value is added to the initial value.

This process is repeated for each attribute for each character.
Describe this process using a suitable algorithm.

Write and test the code to determine these two attributes for a character and store the sample data for two characters, including suitable names, in a file.

Initial Statement.

I’m going to make the start of a game with two characters who each have two attributes ,strength and skill. These will be determined by a 4 and 12 sided dice being rolled then the value of the 12 sided dice will be divided by the value of the 4 sided dice. The result will then be rounded down then added to the initial attribute value of 10. This will be repeated for each attribute for each character. The game will then store a sample of the two attributes for both characters to a text file.

Success Criteria

  • At the start of the game a 4 and 12 sided dice are rolled
  • The value of the 12 sided dice is divided by the value of the 4 sided dice.
  • The result will be rounded down then added to the initial attribute value of 10.
  • The calculation is repeated while setting the results to the attributes corresponding variable
  • The results are outputted to the text file

Task 3 Determining the outcome of an encounter

When there is an encounter between two characters the outcome is determined by the following process:

  • The differences between the strength attributes for the two characters is calculated
  • This difference is divided by 5 and then rounded down to create a ‘strength modifier’
  • The process is repeated for the skill attribute to create a ‘skill modifier’
  • Each player throws a 6 sided dice.
    • If the scores on both dice are the same, no changes are made
    • If the scores are not the same, the player with the highest score adds the ‘strength modifier’ to the strength value and the ‘skill modifier’ to the skill value for their character.
    • The player with the lower score on the dice subtracts these modifiers from the
    • strength and skill values for their character
  • If a skill value becomes negative, then it is stored as zero
  • If a strength value becomes zero or negative, then the character dies.

The program should:

  • Allow the user to input the strength and skill for two characters.
  • Display the outcome of the encounter using the process above.
  • Design an algorithm to describe this process. Write, test and evaluate the code.

Initial Statement.

I’m going to make a program that determines the outcome of an encounter it will allow the user to input the strength and skill for the two characters. The program will then take those values put then though an algorithm to make a strength and skill modifier. A dice will then be rolled for each player the one with the highest dice roll will get the modifiers added to their respected attributes, the one with the lowest will get the modifiers subtracted from their respected attributes. If any characters skill becomes zero or negative it will be stored as zero. If any characters strength becomes zero or negative that character dies this will be the end of the game.

Success criteria

  • The program will allow the user to input the strength and skill for both character
  • The difference between the strength attributes is calculated, divided by 5 and rounded down then stored as the strength modifier.
  • The difference between the skill attributes is calculated, divided by 5 and rounded down then stored as the skill modifier.
  • Both players can roll a 6 sided dice once
  • The results of the dice rolls will be will be compared, if the results are the same nothing will change if the results are different the player with the highest dice roll will get the modifiers added to their respected attributes, the one with the lowest will get the modifiers subtracted from their respected attributes.
  • If any characters skill becomes zero or negative it will be stored as zero.
  • If any characters strength becomes zero or negative that character dies this will be the end of the game.

This task was worth 45 Marks.  It was a controlled assessment task that orginally appeared in OCR GCSE CS until Sept 2014.  All rights and copyright to OCR.  Please refer to the OCR Copyright Statement for further information.  The example Intial Statements and Success Criteria are taken from A453 Sample Material High Band.

Comments 0

Write a Reply or Comment

We will not publish your email.*


*