wordle.py

Created by chambounaudaubin

Created on May 26, 2025

3.44 KB

Ceci est un jeu de réflexion. Entrer un mot existant dans la langue française, le programme ne vérifie pas sa validité car les milliers de mots possibles seraient trop lourds à supporter pour la calculatrice. Enfin il faut jouer le jeu.

Si la lettre se colore en orange, elle est mal placée Si celle-ci se colore en noir, la lettre ne fait pas partie du mot. Si celle-ci se colore en vert, elle est bien placée!

Attention: deux lettres dans le mot entré peuvent être toutes les deux indiquées comme mal placées alors que le mot mystère ne contient qu’une seule fois la lettre!

Reporter les bugs à l’adresse: chambounaudaubin@gmail.com


from kandinsky import *
from ion import *
from time import *
from random import *
dico=["OCEAN","TUILE","MASSE","TAUPE","TAPIS","CHOSE","STYLO","LIVRE","LAMPE","TABLE","RADIO","CHIEN","LAPIN","ALLER","SALLE","ECOLE","ABOIS","GOBER","ENGIN","FORET","ENTRE","ERRER","NAPPE","ESSOR","FATAL","FARCE","FERME","VOLER","OEUFS","RODER","POULE","TERRE","LACET","REVES","CREER","CORPS","CERFS","BICHE","PIEDS","COUTS","CHATS","PIANO","PECHE","AVRIL","FEMME","HOMME","IMAGE","CHARS","CANOT","ROUES","CADRE","AVION","COLLE","GOMME","TITRE","SAUTS","SUITE","PIECE","PAGES","REGLE","BANCS","CARTE"]
wordle,aubin="WORDLE","PAR AUBIN"
lettres=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","p","R","S","T","U","V","W","W","X","Y","Z"]
mot=[]
ligne=1
rp,gp,bp=0,0,0
repl=[]
play=1
xcase=[]
ycase=[]
lcase=[]
ccase=[]
mm=dico[randint(0,len(dico)-1)]
def fin():
  sleep(1)
  for p in range(10):
    fill_rect(int(160-p*28/2)-2,int(111-p*20/2)-2,int(p*28)+4,int(p*20)+4,color(50,100,100))
    fill_rect(int(160-p*28/2),int(111-p*20/2),int(p*28),int(p*20),"white")
    sleep(0.05)
  rp,gp,bp=255,255,255
  for p in range(10):
    draw_string("WORDLE",130,45,color(rp,gp,bp),"white")
    draw_string("Le mot etait "+str(mm),70,75,color(rp,gp,bp),"white")
    if repl==mot:draw_string("Au bout de "+str(ligne)+" essais",65,95,color(rp,gp,bp),"white")
    else:draw_string("Dommage... ",110,95,color(rp,gp,bp),"white")
    draw_string("Jeu par Aubin",90,135,color(rp,gp,bp),"white")
    draw_string("Rejouer?",120,155,color(rp,gp,bp),"white")
    rp,gp,bp=rp-20.5,gp-15.5,bp-15.5
    sleep(0.08)
fill_rect(0,0,320,222,color(230,255,225))
for w in range(len(wordle)):draw_string(str(wordle[w]),20,50+w*20,color(50,100,100),color(230,255,225))
draw_string("ANS",285,202,color(50,100,100),color(230,255,225))
draw_string("?",270,202,"black",color(255,200,200))
for y in range(10,210,35):
  for x in range(80,250,34):
    fill_rect(x,y,30,30,"grey")
    xcase.append(x)
    ycase.append(y)
while True:
  if keydown(KEY_ANS):
    fill_rect(53,43,214,94,"black")
    fill_rect(55,45,210,90,"white")
    draw_string("Entrer un VRAI mot",60,50)
    draw_string("Gris = mauvais",60,70)
    draw_string("Orange = mal place",60,90)
    draw_string("Vert = bon",60,110)
    break
  for l in range(18,45):
    if keydown(l) and len(mot)<5:
      mot.append(lettres[l])
      draw_string(str(lettres[l]),xcase[len(mot)-1]+7,ycase[ligne*5-1]+5,color(70,70,70),"grey")
      while keydown(l):pass
  if keydown(17) and len(mot)>0:
    mot.pop(len(mot)-1)
    draw_string(" ",xcase[len(mot)]+7,ycase[ligne*5-1]+5,color(70,70,70),"grey")
    while keydown(17):pass
  if keydown(KEY_OK) and len(mot)==5 or keydown(KEY_EXE) and len(mot)==5:      
    for p in range(5):
      if mot[p]==mm[p]:ccase.append("green")
      elif mot[p]in mm:ccase.append("orange")
      else :ccase.append(color(50,50,50))
    for l in range(5):fill_rect(80+34*l,ycase[ligne*5-1],30,30,ccase[l])    
    for l in range(5):draw_string(mot[l],80+34*l+5,ycase[ligne*5-1]+5,"white",ccase[l])
    for r in range(5):repl.append(mm[r])
    if mot==repl:
      for l in range(5):fill_rect(80+34*l-1,ycase[ligne*5-1]-1,32,32,color(50,50,50))       
      for l in range(5):fill_rect(80+34*l,ycase[ligne*5-1],30,30,ccase[l])
      for l in range(5):draw_string(mot[l],80+34*l+5,ycase[ligne*5-1]+5,"white",ccase[l])
      break
    if ligne>5:
      fin()
      break
    repl=[]
    mot=[]
    ccase=[]
    ligne=ligne+1  

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.