Delivery in day(s): 4
CSP1150/CSP5110 Programming Principles Assignment Help
Assignment 1 (Dice Game program)
This is an individual programming assignment.
Value:total value of this assessment is 20% and marked out of 20.
This assignment will evaluate your knowledge of the ability to implement the programming concepts which have covered in the unit already, containing the usage of variables, data types, input/output, selection, functions, iteration, and data structures. Except all this, it also evaluates your ability to design and then apply a solution to a problem using these concepts.
You need to design and implement a program that allows the user to play a single-player dice game based loosely on the game ‘Farkle’. The game is played as given below:
a. The game consists of three turns, and the purpose of the game is to score as many as possible
b. Each turn starts with a roll of 6 standard dice
c. Matching dice (two 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’ for example rolling three 5s is worth 15 points
a. The player chooses whether to set matching dice aside and whether to re-roll remaining dice
b. If the player chooses not to re-roll the dice, the points stored in the turn are added to their score and the turn ends
c. If no dice can be put aside after a roll, the player loses the points the potential points and the turn ends- therefore, the player must decide how far to push their luck with additional rolls
The game includes 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 completeness of this program can be in fewer than 100 lines of code (although applying CSP5110 requirements or optional embellishments may result in a program longer than this).
Program Output Example
To support you to visualize the program, here is an example screenshot of the game being played:
As highlighted in the case study of module 5, it’s very important to take the time to appropriately design a solution before starting to write code. However, this task requires you to write and submit pseudocode of your program design along with for the code for the program.
You’ll get 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 create the overall structure of the program and then revise and improve it as you work on the code. This back and forth cycle of designing and coding is entirely usual and expected, especially when you’re new to programming.
The requirements detailed on the following pages should give an idea of the program structure that allows you to start on designing your solution in pseudocode.
Since the structure of the program is relatively complicated, a broad overview has been given below:
This is a general overview that only aims to reflect the general structure of the code and the key steps of processing involved. Your pseudocode should be significantly more detailed.
Write a distinct section of pseudocode for each function you explain in your program so that the code for the major part of your program is not cluttered with function definitions. Make sure that the code for each of your functions clearly defines the considerations that the function receives and what the function returns back to the program.
It will help you to think the pseudocode of your program as the content of a book, and the code of functions as its appendices: it should be possible to read and understand a book without necessarily reading the appendices; however they’re there for further reference if needed.
Only one function is required for this assignment.
You must implement the below-mentioned requirements. In the following information, numbered points define central requirements of the program, and bullet points are additional details, notes, and hints regarding the requirement.
1. The game contains 3 turns. At the start of each turn, print a message indicating which turn it is and the player’s current score.
At the beginning of each turn and set the number of remaining dice to 6, and the points earned this turn to 0.
2. There is an unknown number of rolls in each turn. First of all, simulate rolling the remaining dice by producing a list of random integers between 1 & 6.
a. The number of numbers in the list should match the number of remaining dice.
b. Sort the list so that the rolled numbers are in ascending order using the “.sort ( )” list method.
c. Print the sorted list of numbers for the user to see.
3. Check the rolled dice for matching numbers (two or more 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 to prompt the user to decide whether they wish to set those dice apart by entering ‘yes’ or ‘no’.
a. One approach is to loop through the numbers 1 to 6, using the ‘.count ( )’ list method to define how many of each number appears in the list of numbers.
4. If the user chooses to set apart matching dice, take from 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’, but remember that the points a player earns during a turn are not added to their score until they choose to end the turn.
5. If the player chooses not to set the dice aside, no change is made to the number of dice or points.
a. If no sets of matching dice were set aside in this roll, continue to the next turn without adding the points to their score.
b. A Boolean variable can be used to keep track of whether or not any dice have been set aside.
c. It is possible for the user to roll matching dice and select not to set any of them apart, causing the turn to end.
6. Then, tell the user how many dice are remaining and their current points, and then use the ‘getChoice ( )’ function to prompt the user to decide whether or not to re-roll their remaining dice or end their remaining dice or end their turn by entering ‘roll’ or ‘end’.
It is possible for the player to choose to re-roll when they have fewer than two dice remaining.
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.
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:
a. If their score is minimum 60 points ‘Excellent score, well done!’
b. Otherwise, if their score is minimum 50 points, print ‘Good score!’
c. Otherwise, if their score is minimum 40, print ‘Good score!’
d. Otherwise, don’t print anything.
The ‘getChoice()’ function
Your program must describe a function named ‘getChoice’ that receives 2 parameters:
1. ‘prompt’ – A string containing the text to be shown to the user when getting their input.
2. ‘validChoices’ – A tuple of strings containing the valid responses to the choice.
The function should use these parameters to repeatedly prompt the user for input until they enter one of the valid choices. If they enter anything that is not a valid choice, print ‘invalid choice.’ Once the user enters a valid choice, it should be returned. Applying this function will most likely involve a ‘while’ loop, the ‘in’ comparison operator, and an ‘if’ statement.
Revise Module 4 if you’re struggling to describe or use functions. Confirm that the function receives parameters and returns its results as described – following function specification is important.
Optional Additions and Enhancements
Below are some recommendations for minor additions and improvements that you can make to the program to further test and show your programming ability. They are not required and you can earn full marks in the assignment without applying them.
1. If a turn ends due to not setting any dice apart then stop the program until the user clicks ‘Enter’ between telling them of their misfortune and starting the next turn. It makes the program more user-friendly by giving the user a moment to recognize the end of a turn before being faced with the result of the next turn’s roll.
a. This can be achieved using the ‘input ( )’ function – no need to even store what they enter.
b. If you are applying CSP5110 requirement 2, also pause the program if a turn ends due to having not enough dice remaining.
2. Incorporate special point values for certain mixtures of dice, as follows:
a. Rolling 4 or more 1sis known as an ‘all for one’, worth 20 points. The user still chooses whether or not to set the dice apart.
b. Rolling 1, 2, 3, 4, 5, 6, is known as a ‘straight’, worth 50 points. Since the alternative is ending the turn with 0 points, this should be set without requesting the user to select.
c. Don’t rely on random chance to test that this functionality has been executed correctly. Temporarily change your code to manipulate the rolled dice or create a separate testing program.
3. Use the Unicode characters for dice values in place of the number 1 to 6 whenever you print dice values in the program.
Applying this efficiently is a challenge, but can be done quite elegantly.
Using the ‘enumerate ( )’ function when checking for sets of matching dice can ensure that you have access to an integer variable representing the value of the dice.??
a. Pseudocode (5 marks)
b. Functionality (10 marks)
c. Code Quality (5 marks)
Challenges that students may face while attempting this assignment
Students may face several problems while completing this assignment such as lack of programming skills, insufficient time etc. Such students can take help and academic guidance from our technical experts and excel their records.