Browse Source

Ia fonctionnel avec ajout de lettre et suppression quand elle sont réciproquement bonne et mauvaise résultat insatifaisant

master
philippot.m 2 weeks ago
parent
commit
8756ee1623
  1. 53
      Pendue_que_j_ai_du_refaire_car_je_suis_con.py

53
Pendue_que_j_ai_du_refaire_car_je_suis_con.py

@ -17,7 +17,7 @@ def mot_choisie():
global lst_mot
list_mot_pendue=[]
mot_pendue= mot.get()
#mot_pendue= mot.get()
if len(lst_mot)!=0:
mot_pendue=mot_aleatoire
list_l_pendue=[]
@ -56,8 +56,10 @@ def pendue_jeux(lettre_choisie):
global mot_affiche
global nb_raté
global lettre_à_supp
global lettre_à_supp_av
lettre_trouvé=[]
#recherche si la lettre est dans le mot ou est passé
lettre_à_supp_av=lettre_à_supp[:]
for i_lettre in range(len(list_l_pendue)):
if lettre_choisie==list_l_pendue[i_lettre].lower() and not(lettre_choisie in lettre_à_supp):
lettre_à_supp.append(list_l_pendue[i_lettre])
@ -146,9 +148,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","Felx"]
mot_aleatoire=lst_mot[randint(0,len(lst_mot)-1)]
mot_choisie()
@ -158,26 +160,29 @@ def ai_pendue():
global moment_mort
global difficulté
global lettre_à_supp
lst_lettre=["azertyuiopqsdfghjklmwxcvbn"]*26
lst_lettre=["azertyuiopqsdfghjklmwxcvbn"]*2*25
i=0
while i==0:
moment_mort=8
difficulté=2
nb_essaie=0
victoire=0
rate=0
mot_victoire=[]
while True:
nb_essaie=nb_essaie+1
moment_mort=2
difficulté=4
i=0
aleatoire()
lst_lettre_tire=[]
lettre_à_supp=[]
while not(sorted(list_l_pendue)==sorted(lettre_à_supp) or moment_mort==0):
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")
pendue_jeux(lettre_choisie)
for i_lettre in range(len(list_l_pendue)):
if lettre_choisie == list_l_pendue[i_lettre].lower() and not(lettre_choisie in lettre_à_supp_av):
lst_lettre[i]=lst_lettre[i] + lettre_choisie
break
elif not(lettre_choisie in lettre_à_supp)==True:
elif not(lettre_choisie in lettre_à_supp_av)==True and i_lettre==25:
nb_l_reajouter=-1
for i_lettre in range(0,len(lst_lettre[i])):
if lst_lettre[i][i_lettre] ==lettre_choisie:
@ -186,12 +191,22 @@ def ai_pendue():
if len(lst_lettre[i])==0:
lst_lettre[i]="azertyuiopqsdfghjklmwxcvbn"
break
i=i+1
#print(lst_lettre)
print("fini",nb_essaie)
if nb_essaie %1000==0:
print(lst_lettre,rate,victoire,mot_victoire)
victoire=0
rate=0
mot_victoire=[]
if sorted(list_l_pendue)==sorted(lettre_à_supp):
print("victoir",mot_aleatoire)
print("victoir",mot_aleatoire,nb_essaie)
mot_victoire.append(mot_aleatoire)
victoire=victoire+1
else:
rate=rate+1
##prog principal ##
###############################################
pendue= Tk()

Loading…
Cancel
Save