Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:completed risk-risiko #147

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/ex6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from random import random
#giocatore 1 lancia 3 dadi
k = int(random()*10)
z = int(random()*10)
y = int(random()*10)

giocatore1 = [k,z,y]

a = int(random()*10)
b = int(random()*10)
d = int(random()*10)

giocatore2 = [a,b,d]

counterGiocatore1 = 0
counterGiocatore2 = 0

print("Blue dices:")
print(k)
print(z)
print(y)

print("Red dices:")
print(a)
print(b)
print(d)

if giocatore1[0]>giocatore2[0]:
counterGiocatore1+=1
else:
counterGiocatore2+=1

if giocatore1[1]>giocatore2[1]:
counterGiocatore1+=1
else:
counterGiocatore2+=1

if giocatore1[2]>giocatore2[2]:
counterGiocatore1+=1
else:
counterGiocatore2+=1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

questo codice è un po' ridondante non credi?
forse creando una funzione potresti ridurre la ridondanza, oppure potresti scriverlo meglio con un ciclo for ed in 3 righe te ne esci ;-)


if counterGiocatore1>=counterGiocatore2:
print("Giocatore1 ha vinto")
else:
print("Giocatore2 ha vinto")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qui c'è una ridondanza di codice, potresti salvare in una variabile "winner" il giocatore che vince utiizzando l'operatore ternario e poi scrivere una sola print al posto di scriverne due quasi uguali


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

potresti implementare qualche funzione

Loading