[SOLVED] 代写 data structure algorithm game python CSE 231

30 $

File Name: 代写_data_structure_algorithm_game_python_CSE_231.zip
File Size: 480.42 KB

SKU: 0066355384 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


CSE 231
Spring 2019
Programming Project 03
Edit: 122: default level clarified, specifically default is Easy.
This assignment is worth 20 points 2 of the course grade and must be completed and turned in before 11:59 PM on Monday, January 28, 2019.
Assignment Overview
This assignment will give you more experience on the use of:
1. strings
2. conditionals 3. iteration
4. inputoutput
to create a Typing Game.
Assignment Background
This project asks you to write a program to implement a typing game. In this game, a user earns rewards by quickly typing the correct words shown by the program in a limited time.
Python modules required for this project:
import string
import time
from cse231random import randint
Procedure:
Step 1:
The program starts by prompting the user to choose a hardness level:Enter E or e for the Easy level.
Enter M or m for the Medium level.
Enter H or h for the Hard level.
Hits Enter key for the default level. The default level is Easy.
Q or q to quit the game and stop this program.
If the user enters anything else, you will print out an error message and continually prompt until the user input is valid.
Step 2:
After the user chooses the hardness level, the program will repeatedly
generate a random string with a random length of characters. The length depends on the
chosen hardness level.
prompt the user to enter the correct string. A correct string should contain the same
characters in the same order as generated by your program. It should also be entered within a time interval. The interval depends on the hardness level See the Rules to set the timeout interval below.

user wins rewards if he gets the correct word within the limited time, or fails and get zeros rewards otherwise.
Step 2 will be terminated either when:
the user fails on entering a correct string enters the wrong string or timeout.
the user continuously wins the game 10 times.
Hint: use a for loop for step 2.
After step 2 is complete either the user enters 10 correct inputs, or fails in the middle:
Display the total time spent and the total number of games played in this round
Calculate the rewards earned in the current round by the user.
o ForEasylevel,therewardforonecorrectinputstringis1thenumberofcharacters in that string. For example, if the user chooses the Easy level, and inputs 3 times with the correct string, each string has length 4, 6, 5, then he wins 14161 5 rewards in this round.
o ForMediumlevel,therewardforonecorrectinputstringis2thenumberof characters in that string.
o ForHardlevel,therewardforonecorrectinputstringis3thenumberofcharacters in that string.
Step 3:
Calculate the accumulated rewards earned by the user. Each user has 0 rewards at the beginning of the program.
Example: if a user first chooses the easy level and wins 15 rewards, then chooses the hard level and wins 30 rewards, his total reward after the second run should be:
153045
After step 3, the program will go back to step 1 and prompt the user to choose the hardness level for the next round. If the user quits the game, the program outputs the total number of games played in all rounds and the accumulated rewards earned by the user.
Hint: your game contains a big while loop inside which we repeat step 1step 3.
Example: if a user first chooses the easy level, enters 3 correct inputs and wins 15 rewards, then chooses the hard level, enters 2 correct inputs and wins 30 rewards, the program should output:
Your final total: 520 Your total reward: 45
Rules to set the timeout interval:
For the Easy round, the timeout interval t is 10 seconds.
For the Medium round, the timeout interval t is 9 seconds.
For the Hard round, the timeout interval t is 8 seconds.

Algorithm to check if a user is running out of the time:
1. Before we prompt the user for a correct input string, we use the time.time function to get
the current time t1 in seconds since the Epoch since January 1, 1970.
2. After the user enters a string, we again use the time.time function to get the current time
t2.
3. t2t1 is the time elapsed. If the elapsed time is larger than t, the user will not get any
reward for the string he inputs.
Rules to check if an input string is correct:
A correctly entered string should contain the same letters and the same punctuation in the correct order as the one generated by your program. However, there are some additional rules to be taken care of:
For Easy level, the inputs are caseignorant. For example, if the program generates a string as Hello, your input such as hello, hELLo, etc., will be considered as correct.
For Medium and Hard level, the inputs are casesensitive. For example, if the program
generates a string as Hello!, your input such as hello!, hELLo!, etc., will be
considered wrong, but Hello! will be correct.
For Easy level, we allow users to enter spaces even though the generated string does not
contain spaces. For example, if the program generates a string as Hello, you can input
He l l oas a correct answer.
For Medium and Hard level, spaces are not allowed.
Hints:
use the random.randintlowerbound, upperbound function to help you
generate a random integer.
In the Python console, type the following commands to help you understand what
the random.randint function does:Import random
helprandom.randint
How to generate a random string given the length of the string:Allowed characters include:
For Easy level: all English letters 26 lower case letters and 26 upper case letters. Use ALPHABETEASYstring.asciiletters
For Medium and Hard levels: all English letters and all punctuation. Use
ALPHABETstring.asciilettersstring.punctuation
Rules to generate random words with a random length:
How to choose the random length:
For Easy level, the random lengthshould be bounded in the range 35.
For Medium level, the lengthis bounded by 610.
For Hard level, the lengthis bounded by 1115.

Alright. Now we have an alphabet; how can we generate a random string with length n nN from that? The answer is, we can use a for loop to iterate n times. Each time, we randomly choose one character from the alphabet using an index that we randomly generate.
Hints: use random.randintlowerbound, upperbound to help you generate an index. Please be careful about the lowerbound and upperbound. Your index should be in the range of 0, N1, where N is the length of your alphabet.
A pseudocode for generating a random string with length n is given below:
alphabet Get the alphabet
N get the length of the alphabet
N get the length of the random string you want to generate
wordan empty string for loop iterate n times:
Indexrandom.randintxx, xx
charalphabetindex
Concatenate char to the end of word
Assignment Deliverable
The deliverable for this assignment is the following file: proj03.pythe source code for your Python program
Be sure to use the specified file name and to submit it for grading via the Mimir before the project deadline.
Assignment Notes
1. To clarify the project specifications, sample output is appended to the end of this document.
2. Items 16 of the Coding Standard will be enforced for this project.
3. We provide a proj03.py program for you to start with. It outlines where to place your while
loop notice how input is prompted before the loop and at the bottom of the loop with a for
loop inside.
4. Make sure that the cse231random.py program file is in the same folderdirectory as your
program and that you uncomment the correct VALUES line for the appropriate testthere is a
separate set of VALUES for each test.
5. You are not allowed to use advanced data structures such as list, dictionaries, classes….
6. Hard coding will result in a score of zero. That is, if you tailor your solution to only work for the
test cases instead of working for general cases, you will receive a score of zero.
7. Reminder: programming projects are individual assignments, not to be done collaboratively with
other students. See the syllabus for details.

Test 1:
Please choose the difficulty level:
Ee for Easy;
Mm for Medium;
Hh for Hard;
Hit Enter for Default;
Qq to quit;
Level: e
Level E, game 110
Enter this string: jbGl
jbGl
Good job! You spent0.0 of 10 seconds entering string jbGljbGl
Level E, game 210
Enter this string: tlpks
tlpks
Good job! You spent0.0 of 10 seconds entering string tlpkstlpks
Level E, game 310
Enter this string: hVWT
hVWT
Good job! You spent0.0 of 10 seconds entering string hVWThVWT
Level E, game 410
Enter this string: CJn
CJn
Good job! You spent0.0 of 10 seconds entering string CJnCJn
Level E, game 510
Enter this string: gOiV
gOiV
Good job! You spent0.0 of 10 seconds entering string gOiVgOiV
Level E, game 610
Enter this string: rTY
rTY
Good job! You spent0.0 of 10 seconds entering string rTYrTY
Level E, game 710
Enter this string: HKsxY

HKsxY
Good job! You spent0.0 of 10 seconds entering string HKsxYHKsxY
Level E, game 810
Enter this string: Izeu
Izeu
Good job! You spent0.0 of 10 seconds entering string IzeuIzeu
Level E, game 910
Enter this string: JKm
JKm
Good job! You spent0.0 of 10 seconds entering string JKmJKm
Level E, game 1010
Enter this string: DkJJ
DkJJ
Good job! You spent0.0 of 10 seconds entering string DkJJDkJJ
Result of this game is 1010.
Total time for this game: 0.0
Please choose the difficulty level:
Ee for Easy;
Mm for Medium;
Hh for Hard;
Hit Enter for Default;
Qq to quit;
Level: q
Your final total: 1010
Your total reward: 39

Test 2:
Please choose the difficulty level:
Ee for Easy;
Mm for Medium;
Hh for Hard;
Hit Enter for Default;
Qq to quit;
Level: x
Difficulty level not recognized.
Please choose the difficulty level:
Ee for Easy;
Mm for Medium;
Hh for Hard;
Hit Enter for Default;
Qq to quit;
Level: m
Level M, game 110
Enter this string: !a.j
!a.j
Good job! You spent0.0 of 9 seconds entering string !a.j!a.j
Level M, game 210
Enter this string: FW:yV?
FW:yV?
Good job! You spent0.0 of 9 seconds entering string FW:yV?FW:yV?
Level M, game 310
Enter this string: eFCmSL
a1b2c3
Incorrect. Result of this game is 210.
Total time for this game: 0.0
Please choose the difficulty level:
Ee for Easy;
Mm for Medium;
Hh for Hard;
Hit Enter for Default;
Qq to quit;
Level: q
Your final total: 210
Your total reward: 30

Test 3:
Please choose the difficulty level:
Ee for Easy;
Mm for Medium;
Hh for Hard;
Hit Enter for Default;
Qq to quit;
Level: h
Level H, game 110
Enter this string: SN.pqMzEX
SN.pqMzEX
Good job! You spent0.0 of 8 seconds entering string
SN.pqMzEXSN.pqMzEX
Level H, game 210
Enter this string: J:tOBMzd
J:tOBMzd
Good job! You spent0.0 of 8 seconds entering string
J:tOBMzdJ:tOBMzd
Level H, game 310
Enter this string: o!WBJvTW
o!WBJvTW
Good job! You spent0.0 of 8 seconds entering string
o!WBJvTWo!WBJvTW
Level H, game 410
Enter this string: RJysKF,WSO
xxxx
Incorrect. Result of this game is 310.
Total time for this game: 0.0
Please choose the difficulty level:
Ee for Easy;
Mm for Medium;
Hh for Hard;
Hit Enter for Default;
Qq to quit;
Level: q
Your final total: 310
Your total reward: 114

Test 4:
Please choose the difficulty level:
Ee for Easy;
Mm for Medium;
Hh for Hard;
Hit Enter for Default;
Qq to quit;
Level: h
Level H, game 110
Enter this string: ucqvtwGE?K
ucqvtwGE?K
Good job! You spent0.0 of 8 seconds entering string
ucqvtwGE?KucqvtwGE?K
Level H, game 210
Enter this string: QOngBlXP
QOngBlXP
Good job! You spent0.0 of 8 seconds entering string
QOngBlXPQOngBlXP
Level H, game 310
Enter this string: CwyUDua;re::
xyxz
Incorrect. Result of this game is 210.
Total time for this game: 0.0
Please choose the difficulty level:
Ee for Easy;
Mm for Medium;
Hh for Hard;
Hit Enter for Default;
Qq to quit;
Level: e
Level E, game 110
Enter this string: BLCph
BLCph
Good job! You spent0.0 of 10 seconds entering string BLCphBLCph
Level E, game 210
Enter this string: ikhD

ikhD
Good job! You spent0.0 of 10 seconds entering string ikhDikhD
Level E, game 310
Enter this string: Mslb
Mslb
Good job! You spent0.0 of 10 seconds entering string MslbMslb
Level E, game 410
Enter this string: IziJy
IziJy
Good job! You spent0.0 of 10 seconds entering string IziJyIziJy
Level E, game 510
Enter this string: mOP
mOP
Good job! You spent0.0 of 10 seconds entering string mOPmOP
Level E, game 610
Enter this string: fjTkd
fjTkd
Good job! You spent0.0 of 10 seconds entering string fjTkdfjTkd
Level E, game 710
Enter this string: LNKFf
LNKFf
Good job! You spent0.0 of 10 seconds entering string LNKFfLNKFf
Level E, game 810
Enter this string: XckW
XckW
Good job! You spent0.0 of 10 seconds entering string XckWXckW
Level E, game 910
Enter this string: BeSz
BeSz
Good job! You spent0.0 of 10 seconds entering string BeSzBeSz
Level E, game 1010
Enter this string: psm
psm

Good job! You spent0.0 of 10 seconds entering string psmpsm
Result of this game is 1010.
Total time for this game: 0.0
Please choose the difficulty level:
Ee for Easy;
Mm for Medium;
Hh for Hard;
Hit Enter for Default;
Qq to quit;
Level: m
Level M, game 110
Enter this string: mrRSa
mrRSa
Good job! You spent0.0 of 9 seconds entering string mrRSamrRSa
Level M, game 210
Enter this string: UGUrzj
UGUrzj
Good job! You spent0.0 of 9 seconds entering string UGUrzjUGUrzj
Level M, game 310
Enter this string: Tb!QG
Tb!QG
Good job! You spent0.0 of 9 seconds entering string Tb!QGTb!QG
Level M, game 410
Enter this string: vWPwhHM
abcd1
Incorrect. Result of this game is 310.
Total time for this game: 0.0
Please choose the difficulty level:
Ee for Easy;
Mm for Medium;
Hh for Hard;
Hit Enter for Default;
Qq to quit;
Level: q
Your final total: 1530
Your total reward: 163

Grading Rubric
Computer Project 03 Scoring Summary General Requirements:
4 pts Coding Standard 16
descriptive comments, mnemonic identifiers, format,
etc…
Implementation:
4 pts Test Case 1: Easy
3 pts Test Case 2: Medium
3 pts Test Case 3: Hard
3 pts Test Case 4: All three
3 pts Test Case 5: timing no Mimir test

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 data structure algorithm game python CSE 231
30 $