Browse Source

Ia fonctionnement changé ajout des lettres quand elles sont dans le mot et retire si non bug pour l'ajout et commentaire à ajouter

master
philippot.m 3 weeks ago
parent
commit
a232379ad4
  1. 52
      Pendue_que_j_ai_du_refaire_car_je_suis_con.py

52
Pendue_que_j_ai_du_refaire_car_je_suis_con.py

@ -1,5 +1,6 @@
from tkinter import *
from random import randint
import time
nb_raté=0
moment_mort=2
list_l_pendue=[]
@ -56,9 +57,9 @@ def pendue_jeux(lettre_choisie):
global nb_raté
global lettre_à_supp
lettre_trouvé=[]
#recherche si la lettre est dans le mot
#recherche si la lettre est dans le mot ou est passé
for i_lettre in range(len(list_l_pendue)):
if lettre_choisie==list_l_pendue[i_lettre].lower():
if lettre_choisie==list_l_pendue[i_lettre].lower() and not(lettre_choisie in lettre_à_supp):
lettre_à_supp.append(list_l_pendue[i_lettre])
lettre_trouvé.append(list_l_pendue[i_lettre])
@ -66,7 +67,7 @@ def pendue_jeux(lettre_choisie):
if lettre_choisie==list_mot_pendue[i_changement].lower():
mot_tiret[i_changement]=list_mot_pendue[i_changement]
#créer l'échaffaud
if len(lettre_trouvé) ==0:
if len(lettre_trouvé) ==0 :
moment_mort=moment_mort-1
if difficulté==1:
créer_échaffaud(1+nb_raté)
@ -145,8 +146,9 @@ def choix_niveau():
def aleatoire():
global mot_aleatoire
global lst_mot
lst_mot=["chou","Nouveaux","Pologne","vortex","Emmanuel","Nicolas","mot","pet","chat","chate","zebre","arbre","Donald","canard","bonjour","cote",
"Mexique","France","pomme","Solene","Alabama","anticonstitutionnelement","alcool","jumeau","jumelle","bourré","intergouvernementalisation","Creuse","Elise","abricot","beau","desert","Alaska","jolie","Henry","marche"]
lst_mot=[#"chou","Nouveaux","Pologne","vortex","Emmanuel","Nicolas","mot","pet","chat","chate","zebre","arbre","Donald","canard","bonjour","cote",
#"Mexique","France","pomme","Solene","Alabama","anticonstitutionnelement","alcool","jumeau","jumelle","bourré",
"intergouvernementalisation"]#,"Creuse","Elise","abricot","beau","desert","Alaska","jolie","Henry","marche"]
mot_aleatoire=lst_mot[randint(0,len(lst_mot)-1)]
mot_choisie()
@ -155,41 +157,47 @@ def aleatoire():
def ai_pendue():
global moment_mort
global difficulté
global lettre_à_supp
lst_lettre=["azertyuiopqsdfghjklmwxcvbn"]*26
while True:
i=0
while i==0:
moment_mort=8
difficulté=2
i=0
aleatoire()
lst_lettre_tire=[]
lettre_à_supp=[]
while not(sorted(list_l_pendue)==sorted(lettre_à_supp) or moment_mort==0):
lettre_choisie=lst_lettre[i][randint(0,len(lst_lettre[i])-1)]
pendue_jeux(lettre_choisie)
lst_lettre_tire.append(lettre_choisie)
for i_lettre in range(i+1):
print(lettre_choisie==list_l_pendue[i_lettre].lower() ,not(lettre_choisie in lettre_à_supp) ,lettre_choisie,lettre_à_supp)
if lettre_choisie==list_l_pendue[i_lettre].lower() and not(lettre_choisie in lettre_à_supp):
print("a")
lst_lettre[i]=lst_lettre[i] + lettre_choisie
break
elif not(lettre_choisie in lettre_à_supp)==True:
nb_l_reajouter=-1
for i_lettre in range(0,len(lst_lettre[i])):
if lst_lettre[i][i_lettre] ==lettre_choisie:
nb_l_reajouter=nb_l_reajouter+1
lst_lettre[i]=lst_lettre[i].replace(lst_lettre_tire[i],"") +lettre_choisie*nb_l_reajouter
if len(lst_lettre[i])==0:
lst_lettre[i]="azertyuiopqsdfghjklmwxcvbn"
break
i=i+1
#print(lst_lettre)
if sorted(list_l_pendue)==sorted(lettre_à_supp):
print("gg")
for i in range(0,len(lst_lettre_tire)):
lst_lettre[i]=lst_lettre[i] + lst_lettre_tire[i]
print("victoir",mot_aleatoire)
else:
for i_lst in range(0,len(lst_lettre_tire)):
for i_lettre in range(0,len(lst_lettre[i_lst])):
nb_l_reajouter=-1
if lst_lettre[i_lst][i_lettre] ==lst_lettre_tire[i_lst]:
nb_l_reajouter=nb_l_reajouter+1
lst_lettre[i_lst]=lst_lettre[i_lst].replace(lst_lettre_tire[i_lst],"") +lst_lettre_tire[i_lst]*nb_l_reajouter
if len(lst_lettre[i_lst])==0:
lst_lettre[i_lst]="azertyuiopqsdfghjklmwxcvbn"
print(lst_lettre)
##prog principal ##
###############################################
pendue= Tk()
c = Canvas(width=1000,height=900,bg="white")
c.grid(row=1,column=2,rowspan=8,columnspan=2)
pendue.title("""pendue""")
pendue.title("""Pendue""")
##lettre##
###############################################
lettre = StringVar()

Loading…
Cancel
Save