I am doing a task for a web course about Python basics.
The task asks to make a Rock Paper Scissors game where user selects one choice and then random.randint(0,2)
generates the random choice for computer.
I have already written a working game (Finnish language in variables, functions and prints) :
import random
kierrokset = 0
voitot = 0
tasapelit = 0
def arvoTietokone():
tietokone = random.randint(0,2)
if tietokone == 0:
print("tietokone valitsi: Jalka")
return tietokone
elif tietokone == 1:
print("tietokone valitsi: Ydinase")
return tietokone
else:
print("tietokone valitsi: Torakka")
return tietokone
def arvoVoittaja(pelaaja, tietokone):
global kierrokset, voitot, tasapelit
if pelaaja == "Jalka":
if tietokone == 0:
print("Tasapeli!")
tasapelit += 1
kierrokset += 1
elif tietokone == 1:
print("Hävisit!")
kierrokset += 1
else:
print("Voitit!")
voitot += 1
kierrokset += 1
elif pelaaja == "Ydinase":
if tietokone == 0:
print("Voitit!")
voitot += 1
kierrokset += 1
elif tietokone == 1:
print("Tasapeli!")
tasapelit += 1
kierrokset += 1
else:
print("Hävisit!")
kierrokset += 1
elif pelaaja == "Torakka":
if tietokone == 0:
print("Hävisit!")
kierrokset += 1
elif tietokone == 1:
print("Voitit!")
voitot += 1
kierrokset += 1
else:
print("Tasapeli!")
tasapelit += 1
kierrokset += 1
while True:
pelaaja = input("Jalka, Ydinase vai Torakka? (Lopeta lopettaa): ")
if pelaaja == "Lopeta":
print("Pelasit",kierrokset,"joista voitit",voitot,"ja pelasit tasan",tasapelit,"peliä.")
break
print("Sinä valitsit: ",pelaaja)
tietokone = arvoTietokone()
arvoVoittaja(pelaaja, tietokone)
I have no problems with code itself, but here's the kicker:
The testing platform that the course uses runs 3 different test runs for the code and each time computer choice has to be exactly different one. On Test1 computer choice has to be Rock, on Test2 computer choice must be Paper, and on Test3 computer choice must be Scissors.
How can you produce the choices exactly in that order (Rock, Paper, Scissors) when the choice is generated on random?
It is as if the task wants 3 specific randoms in specific order.
Think it like this:
You first run the program and want the Rock choice for computer, then you close the program, then re-open it and then it has to be Paper, then you close it again and open for the 3rd time and then it has to be Scissors.
Is this logically even possible or is the course task invalid/badly designed?
I already have sent feedback to the teacher handling the course, but I have not yet received a response.
Aucun commentaire:
Enregistrer un commentaire