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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| from random import randrange
from Tkinter import *
#variable
feuille = 0
cailloux = 0
ciseau = 0
feuilleb =0
caillouxb = 0
ciseaub = 0
BOT = 0
pointJ = 0
pointB = 0
#definiton des fonctions
def choix(element) :
global feuille, cailloux, ciseau, feuilleb, caillouxb, cieaub, pointJ, pointB, BOT
####################
##BOT
BOT = randrange(1,3)
if BOT == 1 :
feuilleb += 1
elif BOT == 2 :
caillouxb += 1
elif BOT == 3 :
ciseaub += 1
####################
if element == 1 : #feuille
feuille += 1
if feuille ==1 and feuilleb ==1 :
chaine.configure(fenetre, text ='egaliter !')
elif feuille ==1 and caillouxb == 1 :
chaine.configure(fenetre, text ='Vous gangez un point =P')
pointJ += 1
elif feuille ==1 and ciseaub ==1 :
chaine.configure(fenetre, text ='Vous perdez =(')
pointB += 1
#####################
elif element == 2 : #cailloux
cailloux += 1
if cailloux ==1 and caillouxb ==1 :
chaine.configure(fenetre, text ='egaliter !')
elif cailloux ==1 and feuilleb ==1 :
chaine.configure(fenetre, text ='Vous perdez =(')
pointB += 1
elif cailloux ==1 and ciseaub ==1 :
chaine.configure(fenetre, text ='Vous gagnez un point =P')
pointJ += 1
#####################
elif element == 3 : #ciseau
ciseau += 1
if ciseau ==1 and ciseaub ==1 :
chaine.configure(fenetre, text ='egaliter !')
elif ciseau ==1 and feuilleb ==1 :
chaine.configure(fenetre, text ='Vous gagnez un point =P')
pointJ += 1
elif ciseau ==1 and caillouxb ==1 :
chaine.configure(fenetre, text ='Vous perdez =(')
pointB += 1
# programe IG affichage
fenetre = Tk()
texte1 = Label(fenetre, text='Feuille, cailloux, ciseau, 1 2 3 !')
texte1.pack()
bouton1 = Button(fenetre, text="Feuille", command = (lambda: choix(1)))
bouton1.pack()
bouton2 = Button(fenetre, text="Cailloux", command = (lambda: choix(2)))
bouton2.pack()
bouton3 = Button(fenetre, text="Ciseau", command = (lambda: choix(3)))
bouton3.pack()
bouton4 = Button(fenetre, text="Quitter", command = fenetre.destroy)
bouton4.pack()
chaine = Label(fenetre)
chaine.pack() |
Partager