Csp1150 - design and implement a program that allows the


Assignment - Individual programming assignment

Programming Principles

Background Information
This assignment tests your understanding of and ability to apply the programming concepts we have covered in the unit so far, including the usage of variables, input/output, data types, selection, iteration, functions and data structures. Above all else, it tests your ability to design and then implement a solution to a problem using these concepts.

Assignment Overview
You are required to design and implement a program that allows the user to play a single-player dice game based loosely on the game "Farkle" (although you do not need to be familiar with Farkle). The game is played as follows:
• The game consists of 3 turns, and the aim of the game is to score as many points as possible

• Each turn begins with a roll of 6 standard dice

• Matching dice (2 or more of the same number) can be set aside for points, and the
remaining dice can then be re-rolled in an attempt to score more points
- Points are "amount of dice * number on dice", e.g. rolling three 5s is worth 15 points

• The player chooses whether to set matching dice aside and whether to re-roll remaining dice

• If the player chooses not to re-roll the dice, the points accumulated in the turn are added to their score and the turn ends

• If no dice can be put aside after a roll, the player loses the points the potential points and the turn ends - hence, the player must decide how far to push their luck with additional rolls

The game involves quite a lot of luck, but there is also a small amount of strategy in choosing whether to set matching dice aside and whether to re-roll the remaining dice.

The entirety of this program can be implemented in under 100 lines of code (although implementing CSP5110 requirements or optional additions may result in a program longer than this) - Ask your tutor for advice if you feel your program is unusually long or inefficient.

Pseudocode
As emphasised by the case study of Module 5, it is important to take the time to properly design a solution before starting to write code. Hence, this assignment requires you to write and submit pseudocode of your program design as well as the code for the program. Furthermore, while your tutors are happy to provide help and feedback on your assignment work throughout the semester, they will expect you to be able to show your pseudocode and explain the design of your code.

You will gain a lot more benefit from pseudocode if you actually attempt it before trying to code your program - even if you just start with a rough draft to establish the overall program structure, and then revise and refine it as you work on the code. This back and forth cycle of designing and coding is completely normal and expected, particularly when you are new to programming. The requirements detailed on the following pages should give you a good idea of the structure of the program, allowing you to make a start on designing your solution in pseudocode.

See Reading 3.3 for further information and tips regarding writing good pseudocode.

Since the structure of this program is relatively complex, a broad overview has been provided below:

For each turn
Reset dice and points For each roll
Roll remaining dice
Find matching dice and prompt user to set them aside If no dice set aside
End turn without adding points to score Else
Ask user whether they want to roll again or end turn

If user ends turn
Add points to score and end turn Else
Continue to next roll

Show end of game messages

Write a separate section of pseudocode for each function you define in your program so that the pseudocode for the main part of your program is not cluttered with function definitions. Ensure that the pseudocode for each of your functions clearly describes the parameters that the function receives and what the function returns back to the program.

It may help to think of the pseudocode of your program as the content of a book, and the pseudocode of functions as its appendices: It should be possible to read and understand a book without necessarily reading the appendices, however they are there for further reference if needed.

Only one function is required in this assignment (detailed later in the assignment brief).

Program Requirements
Below are the detailed requirements of the program you must implement. In the following information, numbered points describe a core requirement of the program, and bullet points (in italics) are additional details, notes and hints regarding the requirement. Refer to the earlier information or ask your tutor if you do not understand a requirement or would like further details.

1. The game consists of 3 turns. At the start of each turn, print a message indicating which turn it is and the user's current score.
- At the start of each turn, set the number of remaining dice to 6, and the points earned this turn to 0.

2. In each turn, there are an unknown number of rolls. For each roll, firstly simulate rolling the remaining dice by producing a list of random integers between 1 and 6.
- The amount of numbers in the list should match the number of remaining dice.
- Sort the list so that the rolled numbers are in ascending order using the ".sort()" list method.
- Print the sorted list of numbers for the user to see.

3. Check the rolled dice for matching numbers (i.e. 2 or more of the same number). For each set of matching numbers, print the details of the match and the points it is worth, then use the "getChoice()" function (detailed below) to prompt the user to decide whether they wish to set those dice aside by entering "yes" or "no".
- One approach is to loop through the numbers 1 to 6, using the ".count()" list method to determine how many of each number appears in the list of numbers.

4. If the user chooses to set aside matching dice, subtract the number of dice from their remaining dice and add the points that the matching dice are worth to their points.
- Points are simply "amount of dice * number on dice", but remember that the points a user earns during a turn are not added to their score until they choose to end the turn.
- If the user chooses not to set the dice aside, no change is made to the number of dice or points.

5. If no sets of matching dice were set aside in this roll, continue to the next turn without adding the points to their score.
- A boolean variable can be used to keep track of whether or not any dice have been set aside.
- It is possible (although not very clever) for the user to roll matching dice and choose not to set any of them aside, causing the turn to end.

6. Otherwise, tell the user how many dice are remaining and their current points, and then use the "getChoice()" function (detailed below) to prompt the user to decide whether or not to re- roll their remaining dice or end their turn by entering "roll" or "end".
- It is possible (although again, not very clever) for the user to choose to re-roll when they have fewer than 2 dice remaining. Accounting for this is a CSP5110 requirement.

7. If the user chooses to end their turn, add the points to their score and continue to the next turn. If they choose to re-roll the remaining dice, perform another roll (repeat from Requirement 2).

8. At the end of the third turn, print a "game over" message and their final score. Then, print an additional message if they achieved a score above the following thresholds:
- If their score is at least 60, print "Excellent score, well done!"
- Otherwise, if their score is at least 50, print "Great score!"
- Otherwise, if their score is at least 40, print "Good score!"
- Otherwise, do not print anything.

Attachment:- Tips.rar

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Csp1150 - design and implement a program that allows the
Reference No:- TGS02412857

Expected delivery within 24 Hours