-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchifoumi.py
More file actions
59 lines (44 loc) · 1.58 KB
/
Copy pathchifoumi.py
File metadata and controls
59 lines (44 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Jouer à Chifoumi contre l'ordinateur
import random
coups = ["pierre", "papier", "ciseaux"]
joueur_input = False
print("-----------")
print("Chifoumi v1")
print("-----------\n")
manches = int(input("Combien de manches dans la partie ? "))
partie = 1
points_joueur = 0
points_ordi = 0
while partie <= manches:
joueur_input = False
print("\n-----------")
print(f"Manche n°{partie}")
print("-----------\n")
# coup de l'ordinateur
coup_ordi = random.choice(coups)
# coup du joueur
while joueur_input == False:
coup_joueur = input("Que jouez vous (pierre/papier/ciseaux) ? ")
if coup_joueur in coups:
joueur_input = True
else:
print("choix non valide !")
# la partie
if coup_ordi == coup_joueur:
print("\négalité !")
points_ordi += 1
points_joueur += 1
elif (coup_ordi == "pierre" and coup_joueur == "ciseaux") or (coup_ordi == "ciseaux" and coup_joueur == "feuille") or (coup_ordi == "feuille" and coup_joueur == "pierre"):
print(f"\nl'ordinateur a choisi {coup_ordi}, il a gagné !")
points_ordi += 1
else:
print(f"\nl'ordinateur a choisi {coup_ordi}, il a perdu !")
points_joueur += 1
#affichage des points
print(f"\nscore du joueur: {points_joueur}")
print(f"score de l'ordinateur: {points_ordi}\n")
partie += 1
if points_ordi < points_joueur:
print("\nC'est le joueur qui gagne cette partie !\n")
else:
print("\nC'est l'ordinateur qui gagne cette partie !\n")