bugfix : ne pas utiliser pattern et firsttry ensemble
This commit is contained in:
parent
0ee04abea4
commit
e040749bc1
35
wgamesolv.py
35
wgamesolv.py
@ -25,23 +25,28 @@ def noDouble(mots):
|
||||
return ndList
|
||||
|
||||
|
||||
def firstTryFilter(mots, max_mots):
|
||||
def firstTryFilter(mots, max_mots, pattern):
|
||||
'''
|
||||
First Try : sélectionne des mots ayant des chances de valider ou invalider
|
||||
l'une des lettres les plus utilisée en français
|
||||
l'une des lettres les plus utilisée en français.
|
||||
'''
|
||||
bestLetters = ['E', 'A', 'I', 'R', 'S', 'N', 'T', 'O', 'L', 'U']
|
||||
bestWords = []
|
||||
shuffle(mots)
|
||||
mots = mots[:100]
|
||||
for mot in mots:
|
||||
for bestLetter in bestLetters:
|
||||
if bestLetter in mot:
|
||||
bestWords.append(mot)
|
||||
bestWords = list(set(bestWords))
|
||||
bestWords = noDouble(bestWords) # Autant maximiser les chances
|
||||
bestWords = bestWords[:max_mots]
|
||||
return(bestWords)
|
||||
if pattern:
|
||||
return mots # Inhibe le filtre si on utilise aussi un pattern
|
||||
else:
|
||||
bestLetters = ['E', 'A', 'I', 'R', 'S', 'N', 'T', 'O', 'L', 'U']
|
||||
bestWords = []
|
||||
shuffle(mots)
|
||||
mots = mots[:100]
|
||||
for mot in mots:
|
||||
for bestLetter in bestLetters:
|
||||
if bestLetter in mot:
|
||||
bestWords.append(mot)
|
||||
bestWords = list(set(bestWords))
|
||||
bestWords_noDouble = noDouble(bestWords) # Autant maximiser les chances
|
||||
if len(bestWords_noDouble) > 0:
|
||||
bestWords = bestWords_noDouble
|
||||
bestWords = bestWords[:max_mots]
|
||||
return bestWords
|
||||
|
||||
|
||||
def resolv_fl(liste, firstletter):
|
||||
@ -182,7 +187,7 @@ if __name__ == "__main__":
|
||||
if args.badLetters:
|
||||
liste = resolv_bl(liste, args.badLetters)
|
||||
if args.firstTry:
|
||||
liste = firstTryFilter(liste, args.firstTry)
|
||||
liste = firstTryFilter(liste, args.firstTry, args.pattern)
|
||||
if len(liste) == 1:
|
||||
print(f"Essaie : \"{liste[0]}\"")
|
||||
elif len(liste) > 1:
|
||||
|
Loading…
Reference in New Issue
Block a user