I'm pretty sure I have a complete solution to Wordle.  Some years ago I wrote a program to play Jotto, which has a scoring system that only gives you 1 point per letter matched, with no indication of what letter matches.  I modified it for Wordle scoring.

[If I'm so smart, why can't I sell my program for a million bucks?]

My function for scoring Wordle is

wdtouniq =: ([: {&a. a.&i. + 26 * i.~ (] - {) /:@/:)"1 NB. replace each letter with combination letter/# previous identical letters NB. Exact matches count 2 and override the result in that position.  Otherwise, if NB. a letter/ordinal appears anywhere in the other word, it counts as a simple match
NB. y is the guess, x is the hidden word
wrdcmp=: ((e. + =)/@:wdtouniq)@:(({.a.)&((0 5 +/ I.@(=/)@])}))@:,: ~

wrdcmp finds identical letters and replaces them with NUL.  Then, it replaces each letter with (repeat#,letter) where repeat# is the number of previous letters equal to the given letter (it encodes these into 1 byte rather than making them 2 values).  Then it looks for matches.

That's just the beginning.

To play the game right, it isn't sufficient to calculate the entropy of the possible calls.  You have to recur to the bitter end, calculating the expected # turns of each active set of words, because you are only allowed to call valid words.

Before you start, you have to have a dictionary with a probability associated with each word.  You could make them all identical, if you really think the hidden word is just as likely to be 'zloty' as 'crate'; but I weighted the words according to their likelihood in English text, but reducing the weight of the most common words.  Defining the dictionary is what really defines the game to be played.

With the dictionary and probabilities I have, I can report that the expected number of turns for the best initial calls are

tears  3.40429
slate  3.4155
tales  3.42104
tries  3.4317
stale  3.43402
rates  3.43807
...

Henry Rich




On 2/16/2022 7:26 PM, Ian Clark wrote:
Being my usual helpful wee self, I was about to proffer this worked example
by 3Blue1Brown on calculating the best first guess:

[1] https://www.youtube.com/watch?v=v68zYyaEmEA

when 3Blue1Brown posted a retraction:

[2] https://www.youtube.com/watch?v=fRed0Xmc2Wg

He'd used the wrong hashing algorithm (if we may call it that). The video
details his error plus the correction, and reruns the entropy calculations.


AFAICS Raul has taken the necessary first step in bringing some sanity to
this topic. A universally-agreed acceptance test for what he calls *wrdcmp*.


Could some kind benefactor of humanity please expand Raul's list of asserts
to reconcile

    - the original Wordle source code, e.g. at:
    https://www.wordleunlimited.com
    - 3Blue1Brown's retraction, [2] above
    - https://rosettacode.org/wiki/Wordle_comparison -which links:
    - en.wikipedia.org/wiki/Wordle#Gameplay


WIBNI (wouldn't-it-be-nice-if) the acceptance test could be run against all
the submissions to RosettaCode.


A version of the acceptance test for Mastermind would be nice as well,
since there are non-isomorphic variants of that too.


Importance: medium to high. Both Mastermind and Wordle are excellent
paradigms for teaching Information Theory, in a form applicable to IT
rather than to Bayesian statistics.


What do I mean by that? The IT world needs a formulation of entropy that
avoids relying on the notion of probability. Moreover, Bayes Rule and
treatments using it are vastly simplified when expressed in bits instead of
probability ratios.

On Wed, 16 Feb 2022 at 22:23, Raul Miller <rauldmil...@gmail.com> wrote:

On Wed, Feb 16, 2022 at 4:57 PM 'Pascal Jasmin' via Programming
<programm...@jsoftware.com> wrote:
the score funtion is what you are looking for.  is super elegant, but
does not meet the spec of scoring 0 instead of 1 when there are extra
copies of a candidate letter above and beyond the count in the secret.  The
elegance.
score =: e.~ + =
It's viable to solve wordle using just counts of exact and inexact
matches (without knowing their positions nor the letters). The
approach is to start with a dictionary of possibilities and exclude
everything shown to be impossible.

Being able to select exact and inexact letter matches, like your
approach here, is also viable. That same approach works, though the
details of which dictionary words match or do not match is a bit
different.

Having the right dictionary is probably the most important facet of
implementing a wordle solver.

That said, I guess should include my current best effort:

wrdcmp=: {{
   yw=. ;(] , ({.~1<.#)@-.)&.>/(<@I.y=/~x#~y~:x),<I.x=y
   2 (I.x=y)} 1 yw} (#y)#0
}}

assert 1 1 2 0 0-: 'allow' wrdcmp 'lolly'
assert 0 0 2 2 2-: 'bully' wrdcmp 'lolly'
assert 0 0 0 1 0-: 'robin' wrdcmp 'alert'
assert 0 2 1 2 0-: 'robin' wrdcmp 'sonic'
assert 2 2 2 2 2-: 'robin' wrdcmp 'robin'
assert 0 0 2 1 0-: 'mamma' wrdcmp 'nomad'
assert 0 1 2 0 0-: 'nomad' wrdcmp 'mamma'

This is a bit more elaborate than your 'score' but it's not too bad.

Thanks,

--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


--
This email has been checked for viruses by AVG.
https://www.avg.com

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to