Тёмный
No video :(

Solving Wordle in under 3 guesses with python 

The Dodgy Engineer
Подписаться 1,3 тыс.
Просмотров 8 тыс.
50% 1

Опубликовано:

 

25 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 48   
@Seuis
@Seuis 2 года назад
Informative video!
@shopt6933
@shopt6933 2 года назад
Just stumbled across this. I think there are a couple of things which make this look better than it is. Firstly using the wordle answer list ranges from cheating to merely overfitting depending on your point of view. Having said that, 3Blue1Brown gets around 3.4 even when using the wordle answer list. Secondly, you say you are removing answers that have previously appeared. That's what allows you to beat 3Blue1Brown and most of the other solvers out there, which start with a clean slate (no I didn't pick that word deliberately) for each word they are solving. It's an interesting approach (it's similar to the one I used in my first solver, though I used the sum of the logs of the letter counts instead, your scoring is probably better). I've implemented another solver similar to the 3B1B approach, it will be interesting to see how it compares to your numbers if I also drop already seen answers each time. I may get around to that and report back.
@TheDodgyEngineer
@TheDodgyEngineer 2 года назад
Maybe it is borderline cheating, but my approach is the same as I would do as a human player (i.e. never guess a word that I know it cannot be). If you find out something interesting, it would be great to share!
@shopt6933
@shopt6933 2 года назад
@@TheDodgyEngineer I'm back. So yes a human could in theory remember all the previous answers. The bit that many would consider cheating is knowing the list of 2315 words (which has changed to 2309 words since this video) that the answers come from. Without that, remembering previous answers is substantially less useful. Even with the wordle answer list, remembering previous answers only really starts to pay off after a few years of wordle play. Anyway, I did some testing. My solver based on 3B1B maths scores an average of 3.10 when using the same test method as you do. If I test your solver using the same method most others do (I took out the numpy random fuzzing and added an auto-marker), it seems it averages 3.68 (compared to 3.43 for mine and 3B1B). I tried to replicate the results of your video with your code, though I got 2.98 rather than 2.95. I can't explain the 0.03 discrepancy, but it's fairly small so I didn't investigate further. I'm genuinely surprised by these results. It seems your letter frequency method performs quite well with a small list of possible answers. My theory is that it stumbles onto the correct answer early by luck whereas the 3B1B-style, entropy-based solvers are trying harder to be certain of the answer, even guessing words that they know to be impossible because that will narrow down the options more. I should probably tweak my solver to more strongly prefer guesses that are actually possible if I keep trying to use it with small answer lists. The entropy based solvers scale much better to larger answer lists (like the 12972-word allowed-guess list a lot of solvers use in order to play "fairer"). I know from having written a letter-position frequency based solver like yours it can get stuck really badly on certain words where it has worked out 4 letters and then tries to find the last letter by going through words mostly arbitrarily. eg. there are 8 words in the allowed-guess list that end in "inge", 10 that end in "atch", 10 that end in "itch", 7 that start with "tri" and end in "e", etc.
@TheDodgyEngineer
@TheDodgyEngineer 2 года назад
@@shopt6933 This is really cool, such dedication to the project haha! How does an entropy based solver avoid the "inge" situation, because each possible starting letter has equal probability? Does it just guess a word that cannot be correct, but utilises as many of the possible starting letters?
@shopt6933
@shopt6933 2 года назад
@@TheDodgyEngineer One way is weighting words, but you are asking about all being equally likely, so I'll leave word weighting aside. In some ways it's simpler than what you suggest as the technique just falls out from the maths. The effect often turns out as you describe, but it's not always a sudden transition, ie. it might see that there's not a lot of information to be gained in the 2nd-5th letters and start leaning towards words which rule more 1st letters in/out, even before it knows precisely what are in spots 2-5. In general though, entropy based solvers are always looking for which word will give the most informative results on average, and knowing you will get 4 greens from your guess is not very informative. To make things a bit more concrete, of the 8 "inge" words in the 12972 word guess list (they start with bdghmstw), 3 are actually possible wordle answers (bhs). If I give my solver no information beyond the 12972 word list (ie. neither the wordle answer list nor any word weightings), it gets "singe" in 4 and "binge"/"hinge" in 5. I'll try to step through the solve for "hinge" here (though the solve for "binge" is identical except for the final "guess"). Guess 1: "tares" (not the best guess if you know the wordle answer list, heavily slanted by the number of plurals and words ending in "ed" that are in the 12972 list but absent from possible wordle answers). Result is bbbyb. So we already eliminated "tinge" and "singe". 637 possible words remain. Guess 2: "doily". The solver knows it's not the answer (as we don't have an 'e') but nevertheless thinks this will be the most informative word on average. Result is bbybb. We've now also eliminated "dinge". 58 possible words remain. Guess 3: "menge". Once again, known not to be the answer (no 'i'). We can guess that the solver is trying to rule the "nge" suffix in/out, and also pin down the location of the e (though it's really just following the maths). Result is bbggg. We also rule out the "inge" word that starts with 'm' (not sure exactly what the rules are on YT so I don't want to type the word). 4 possible words remain, all of them "inge" words. Guess 4: "howbe". Obviously not the answer. We can see it's going for the b, h, w, and will know it's the g if they are all not in the answer. So this guess is guaranteed to leave us with 1 valid word for a guaranteed solve on guess 5. We got lucky that there was a word that would cover 3 of the 4 letters, in fact this was the only one in the 12972 words which would do so. Plenty of other words only covered 2 letters, which would leave us with a 50% chance of a 50/50 on guess 5. This would have at least guaranteed a solve on guess 6, whereas walking through the "inge" words one at a time has a 25% chance of needing a 7th guess.
@fanytasticsone655
@fanytasticsone655 2 года назад
I recreated your program on my own, but there's a thing. In 2:37, Why you choose cumulative multiple product, rather than comparing euclidean distance? (or vector difference)
@TheDodgyEngineer
@TheDodgyEngineer 2 года назад
Using a product amplifies the difference in score compared to simply summing the differences. The idea being that with using a product, a larger range of scores are possible, reducing the chance two words score the same. Maybe that's flawed logic, but using distance shouldn't make a difference really.
@user-iz8xe5pf2q
@user-iz8xe5pf2q 2 года назад
Could you upload many videos about your sixth form tips or studying tips?
@TheDodgyEngineer
@TheDodgyEngineer 2 года назад
I have some content relating to this coming soon!
@confused398
@confused398 6 месяцев назад
Can I use this in one of my personal projects, it'll be used in a public github repository? I would credit you and drop a link to this video. Thanks
@alebr5015
@alebr5015 Год назад
@TheDodgyEngineer what do possible_words and frequencies correspond to in the function you defined?
@TheDodgyEngineer
@TheDodgyEngineer Год назад
Possible words is the list of acceptable answers, frequencies are defined from possible words using letterFreq()
@scamperYT
@scamperYT 2 года назад
i ran the py file in the description but it just closes instantly, please help
@TheDodgyEngineer
@TheDodgyEngineer 2 года назад
Try using VS code to run it
@aswinr6539
@aswinr6539 3 месяца назад
Welcome to the Wordle Solver! The suggested starting word is: slate Enter your first guess: slate Enter your first result: wwyyy ['begat', 'adept', 'after', 'facet', 'agent', 'water', 'taken', 'terra', 'cadet', 'tweak', 'wheat', 'taker', 'extra'] The suggested word is: taker Enter your next guess: taker Enter your new result: ggwgg [] Oh no! You made a mistake entering one of your results. Please try again. === Code Execution Successful === I am getting this issue my word is taper, which is present in your dictionary
@TonyWhitley
@TonyWhitley 2 месяца назад
There is a bug in the code or the algorithm, I had the equivalent outcome trying it today.
@TonyWhitley
@TonyWhitley 2 месяца назад
Printing "You made a mistake" is adding insult to injury 🙂
@aswinr6539
@aswinr6539 2 месяца назад
​@@TonyWhitley sorry didn't meant that way😬
@KillBill1299
@KillBill1299 2 года назад
would love a tutorial on how to download this
@TheDodgyEngineer
@TheDodgyEngineer 2 года назад
I'll upload to GitHub soon!
@thomasgrantduck321
@thomasgrantduck321 2 года назад
@@TheDodgyEngineer Still waiting 😞
@zMarcusHD
@zMarcusHD 2 года назад
hmm i tried implementing this solving algorithm into my wordle api and i am only getting a 90% solve rate. it seems to do really well for the most part until for example, i get to a word like 'joyed', where it ends up cycling through a bunch of _o_ed words seemingly at random before failing. i.e. it played coned, bowed, doped, domed, joked. is it possible i have implemented it incorrectly? my api gives me a list of remaining words, and from that i am able to create a dictionary of letter frequencies in position. then i was able to essentially copy and paste the algorithm on screen and generate a list of words and their respective scores and play the word with the lowest score. I also began each turn with slate. is there a reason why you haven't posted this up on github? if it actually can on average get it in 2.9 guesses, that is pretty remarkable for such little code
@TheDodgyEngineer
@TheDodgyEngineer 2 года назад
This algorithm isn't necessarily going to guess the correct answer every time, but I think it should be better than 90%? However, I'm not a very experienced programmer so I'm sure I've over-looked various cases/bugs! A GitHub link is now in the description, have fun dissecting my garbage code haha
@zMarcusHD
@zMarcusHD 2 года назад
@@TheDodgyEngineer it must be better than 90% because that's what I get when I randomize my possible/remaining wordslist for each guess. ill give it a crack now
@zMarcusHD
@zMarcusHD 2 года назад
@@TheDodgyEngineer ok turns out part of my word remover algorithm was wrong, so that's why it wasn't working for me. i wrapped your code in a loop choosing a random word each time to guess, and it had a 97% solve rate after 1000 games. awesome stuff
@TheDodgyEngineer
@TheDodgyEngineer 2 года назад
@@zMarcusHD Glad to hear someone is having fun with my code!
@yuechen-jc5fc
@yuechen-jc5fc Год назад
could you plz share the code of the results that showed at 3:02? how does the code run itself and compute the average number and runtime?
@TheDodgyEngineer
@TheDodgyEngineer Год назад
It's just a for loop that runs over the set of Wordle words
@SUSUS22641
@SUSUS22641 Год назад
how to run the code
@kev7127
@kev7127 2 года назад
worlde word list?
@bean1749
@bean1749 2 года назад
github link?
@thomasgrantduck321
@thomasgrantduck321 2 года назад
Source?
@TheDodgyEngineer
@TheDodgyEngineer 2 года назад
3Blue1Brown
@marcosgarces7962
@marcosgarces7962 2 года назад
is the code uploaded to github if yes could you share it?
@TheDodgyEngineer
@TheDodgyEngineer 2 года назад
I've added a link to the video description!
@jerryshi6331
@jerryshi6331 2 года назад
Source please
@TheDodgyEngineer
@TheDodgyEngineer 2 года назад
Fine. I'll upload it soon.
@Vee-Hive
@Vee-Hive 2 года назад
no way are you getting under 3 guesses with a dictionary of 13000 words!
@TheDodgyEngineer
@TheDodgyEngineer 2 года назад
I'm not using 13000 words, I'm using the Wordle set!
@Vee-Hive
@Vee-Hive 2 года назад
@@TheDodgyEngineer Well that explains that. Now do your test with the FULL Wordle dictionary of 13000 words and report your figures here.
@TheDodgyEngineer
@TheDodgyEngineer 2 года назад
@@Vee-Hive Sorry, but I'm too busy working on other things right now to revisit this project!
@abhisheksaikia4561
@abhisheksaikia4561 2 года назад
Source plz?
@fanytasticsone655
@fanytasticsone655 2 года назад
Today's puzzle it need 4 times
@TheDodgyEngineer
@TheDodgyEngineer 2 года назад
Just because sometimes it does it in 4 doesn't mean it can't have a lower average
@anirudhraovasudevarao3211
@anirudhraovasudevarao3211 2 года назад
Why is the frequency in Xyzaa not “0,0,0,1,2” for the letter ‘a’
@TheDodgyEngineer
@TheDodgyEngineer 2 года назад
xyzaa is the second word, and the dictionary contains cumulative frequencies, so [1, 1, 1, 2, 2]
Далее
Solving Wordle using information theory
30:38
Просмотров 10 млн
The best Wordle strategy - according to science
12:33
Просмотров 894 тыс.
HOW DID SHE DECIDE TO DO THIS?!
00:27
Просмотров 6 млн
Cute kitty gadgets 💛
00:24
Просмотров 10 млн
Text-Based Wordle in Python under 15 Minutes!
21:03
Просмотров 15 тыс.
Someone improved my code by 40,832,277,770%
28:47
Просмотров 2,5 млн
10 FORBIDDEN Sorting Algorithms
9:41
Просмотров 845 тыс.
i'm so tired of talking about this..
10:00
Просмотров 28 тыс.
Rotation without rotating.
16:52
Просмотров 1 млн
Learn To Code Like a GENIUS and Not Waste Time
9:41
Просмотров 1,5 млн
Perfect WORDLE algorithm (and how I found it)
18:03
Просмотров 12 тыс.
Using AI to Create the Perfect Keyboard
12:05
Просмотров 1,4 млн