partial_word = ask_partial_word( partial_word ) else: fails += 1 # Si c'est la dernière chance mais qu'il reste trop de mots à tester if fails == len(pendu.BOARDS_PIC) and len(words) > 1: # on tente au hasard print("Je pense au mot «",random.choice(words),"»") return ask_correct() if "_" not in partial_word: return True return False if __name__=="__main__": print("Entrez votre mot secret") word_size = len( input() ) partial_word = "_" * word_size words = pendu.filter_wordsize( pendu.download_dic( "http://nojhan.net/aapssfc/data/french_dictionary.utf8" ), word_size ) won = play( partial_word, words ) if won: print("J'ai gagné :-)") else: print("J'ai perdu :-(")
return False if __name__=="__main__": games = 100 all_words = pendu.download_dic( "http://nojhan.net/aapssfc/data/french_dictionary.utf8" ) all_played = 0 all_won = 0 lost_on = [] # Essais des mots de tailles variables for word_size in range(1,20): words = pendu.filter_wordsize( all_words, word_size ) print(len(words),"mots de taille",word_size,"...") # Joue sur quelques mots tirés au hasard played = 0 won = 0 for r in range(games): secret_word = random.choice( words ) if auto_play( secret_word, words ): won += 1 else: lost_on.append( secret_word ) played += 1 print("\tvictoires :",won,"/",played) all_won += won