bzimmer / qordle

Simple wordle solver
MIT License
0 stars 0 forks source link

In a guessing game, use a word which returns the maximum information #40

Closed bzimmer closed 1 year ago

bzimmer commented 1 year ago

In the case the secret word is layer, the algorithms fail to identify the secret quickly because so many words have a similar construction. In this case, if the edit distance for all the remaining words is 1 then find a word which has as many of remaining letters as possible for the next guess.

~ > qordle suggest so~a~r~e dAtER gApER LAcER
["laker","lamer","laver","lawer","laxer","layer"]
~ > qordle play layer | jq
{
  "secret": "layer",
  "strategy": "frequency",
  "rounds": [
    {
      "dictionary": 12947,
      "next": "dater",
      "scores": [
        "so~a~r~e"
      ],
      "words": [
        "soare"
      ],
      "success": false
    },
    {
      "dictionary": 257,
      "next": "gaper",
      "scores": [
        "so~a~r~e",
        "dAtER"
      ],
      "words": [
        "soare",
        "dater"
      ],
      "success": false
    },
    {
      "dictionary": 66,
      "next": "lacer",
      "scores": [
        "so~a~r~e",
        "dAtER",
        "gApER"
      ],
      "words": [
        "soare",
        "dater",
        "gaper"
      ],
      "success": false
    },
    {
      "dictionary": 42,
      "next": "laker",
      "scores": [
        "so~a~r~e",
        "dAtER",
        "gApER",
        "LAcER"
      ],
      "words": [
        "soare",
        "dater",
        "gaper",
        "lacer"
      ],
      "success": false
    },
    {
      "dictionary": 6,
      "next": "lamer",
      "scores": [
        "so~a~r~e",
        "dAtER",
        "gApER",
        "LAcER",
        "LAkER"
      ],
      "words": [
        "soare",
        "dater",
        "gaper",
        "lacer",
        "laker"
      ],
      "success": false
    },
    {
      "dictionary": 5,
      "next": "laver",
      "scores": [
        "so~a~r~e",
        "dAtER",
        "gApER",
        "LAcER",
        "LAkER",
        "LAmER"
      ],
      "words": [
        "soare",
        "dater",
        "gaper",
        "lacer",
        "laker",
        "lamer"
      ],
      "success": false
    },
    {
      "dictionary": 4,
      "next": "lawer",
      "scores": [
        "so~a~r~e",
        "dAtER",
        "gApER",
        "LAcER",
        "LAkER",
        "LAmER",
        "LAvER"
      ],
      "words": [
        "soare",
        "dater",
        "gaper",
        "lacer",
        "laker",
        "lamer",
        "laver"
      ],
      "success": false
    },
    {
      "dictionary": 3,
      "next": "laxer",
      "scores": [
        "so~a~r~e",
        "dAtER",
        "gApER",
        "LAcER",
        "LAkER",
        "LAmER",
        "LAvER",
        "LAwER"
      ],
      "words": [
        "soare",
        "dater",
        "gaper",
        "lacer",
        "laker",
        "lamer",
        "laver",
        "lawer"
      ],
      "success": false
    },
    {
      "dictionary": 2,
      "scores": [
        "so~a~r~e",
        "dAtER",
        "gApER",
        "LAcER",
        "LAkER",
        "LAmER",
        "LAvER",
        "LAwER",
        "LAxER"
      ],
      "words": [
        "soare",
        "dater",
        "gaper",
        "lacer",
        "laker",
        "lamer",
        "laver",
        "lawer",
        "laxer"
      ],
      "success": false
    },
    {
      "dictionary": 1,
      "scores": [
        "so~a~r~e",
        "dAtER",
        "gApER",
        "LAcER",
        "LAkER",
        "LAmER",
        "LAvER",
        "LAwER",
        "LAxER",
        "LAYER"
      ],
      "words": [
        "soare",
        "dater",
        "gaper",
        "lacer",
        "laker",
        "lamer",
        "laver",
        "lawer",
        "laxer",
        "layer"
      ],
      "success": true
    }
  ]
}
{
  "secret": "years",
  "strategy": "frequency",
  "rounds": [
    {
      "dictionary": 12947,
      "next": "bears",
      "scores": [
        "~soAR~e"
      ],
      "words": [
        "soare"
      ],
      "success": false
    },
    {
      "dictionary": 12,
      "next": "dears",
      "scores": [
        "~soAR~e",
        "bEARS"
      ],
      "words": [
        "soare",
        "bears"
      ],
      "success": false
    },
    {
      "dictionary": 11,
      "next": "fears",
      "scores": [
        "~soAR~e",
        "bEARS",
        "dEARS"
      ],
      "words": [
        "soare",
        "bears",
        "dears"
      ],
      "success": false
    },
    {
      "dictionary": 10,
      "next": "gears",
      "scores": [
        "~soAR~e",
        "bEARS",
        "dEARS",
        "fEARS"
      ],
      "words": [
        "soare",
        "bears",
        "dears",
        "fears"
      ],
      "success": false
    },
    {
      "dictionary": 9,
      "next": "hears",
      "scores": [
        "~soAR~e",
        "bEARS",
        "dEARS",
        "fEARS",
        "gEARS"
      ],
      "words": [
        "soare",
        "bears",
        "dears",
        "fears",
        "gears"
      ],
      "success": false
    },
    {
      "dictionary": 8,
      "next": "lears",
      "scores": [
        "~soAR~e",
        "bEARS",
        "dEARS",
        "fEARS",
        "gEARS",
        "hEARS"
      ],
      "words": [
        "soare",
        "bears",
        "dears",
        "fears",
        "gears",
        "hears"
      ],
      "success": false
    },
    {
      "dictionary": 7,
      "next": "nears",
      "scores": [
        "~soAR~e",
        "bEARS",
        "dEARS",
        "fEARS",
        "gEARS",
        "hEARS",
        "lEARS"
      ],
      "words": [
        "soare",
        "bears",
        "dears",
        "fears",
        "gears",
        "hears",
        "lears"
      ],
      "success": false
    },
    {
      "dictionary": 6,
      "next": "pears",
      "scores": [
        "~soAR~e",
        "bEARS",
        "dEARS",
        "fEARS",
        "gEARS",
        "hEARS",
        "lEARS",
        "nEARS"
      ],
      "words": [
        "soare",
        "bears",
        "dears",
        "fears",
        "gears",
        "hears",
        "lears",
        "nears"
      ],
      "success": false
    },
    {
      "dictionary": 5,
      "next": "tears",
      "scores": [
        "~soAR~e",
        "bEARS",
        "dEARS",
        "fEARS",
        "gEARS",
        "hEARS",
        "lEARS",
        "nEARS",
        "pEARS"
      ],
      "words": [
        "soare",
        "bears",
        "dears",
        "fears",
        "gears",
        "hears",
        "lears",
        "nears",
        "pears"
      ],
      "success": false
    },
    {
      "dictionary": 4,
      "next": "wears",
      "scores": [
        "~soAR~e",
        "bEARS",
        "dEARS",
        "fEARS",
        "gEARS",
        "hEARS",
        "lEARS",
        "nEARS",
        "pEARS",
        "tEARS"
      ],
      "words": [
        "soare",
        "bears",
        "dears",
        "fears",
        "gears",
        "hears",
        "lears",
        "nears",
        "pears",
        "tears"
      ],
      "success": false
    },
    {
      "dictionary": 3,
      "scores": [
        "~soAR~e",
        "bEARS",
        "dEARS",
        "fEARS",
        "gEARS",
        "hEARS",
        "lEARS",
        "nEARS",
        "pEARS",
        "tEARS",
        "wEARS"
      ],
      "words": [
        "soare",
        "bears",
        "dears",
        "fears",
        "gears",
        "hears",
        "lears",
        "nears",
        "pears",
        "tears",
        "wears"
      ],
      "success": false
    },
    {
      "dictionary": 2,
      "scores": [
        "~soAR~e",
        "bEARS",
        "dEARS",
        "fEARS",
        "gEARS",
        "hEARS",
        "lEARS",
        "nEARS",
        "pEARS",
        "tEARS",
        "wEARS",
        "YEARS"
      ],
      "words": [
        "soare",
        "bears",
        "dears",
        "fears",
        "gears",
        "hears",
        "lears",
        "nears",
        "pears",
        "tears",
        "wears",
        "years"
      ],
      "success": true
    }
  ]
}
bzimmer commented 1 year ago
{
  "secret": "start",
  "strategy": "frequency",
  "rounds": [
    {
      "dictionary": 12947,
      "next": "starn",
      "scores": [
        "SoARe"
      ],
      "words": [
        "soare"
      ],
      "success": false
    },
    {
      "dictionary": 31,
      "next": "stark",
      "scores": [
        "SoARe",
        "STARn"
      ],
      "words": [
        "soare",
        "starn"
      ],
      "success": false
    },
    {
      "dictionary": 4,
      "next": "starr",
      "scores": [
        "SoARe",
        "STARn",
        "STARk"
      ],
      "words": [
        "soare",
        "starn",
        "stark"
      ],
      "success": false
    },
    {
      "dictionary": 3,
      "next": "stars",
      "scores": [
        "SoARe",
        "STARn",
        "STARk",
        "STARr"
      ],
      "words": [
        "soare",
        "starn",
        "stark",
        "starr"
      ],
      "success": false
    },
    {
      "dictionary": 2,
      "scores": [
        "SoARe",
        "STARn",
        "STARk",
        "STARr",
        "STARs"
      ],
      "words": [
        "soare",
        "starn",
        "stark",
        "starr",
        "stars"
      ],
      "success": false
    },
    {
      "dictionary": 1,
      "scores": [
        "SoARe",
        "STARn",
        "STARk",
        "STARr",
        "STARs",
        "START"
      ],
      "words": [
        "soare",
        "starn",
        "stark",
        "starr",
        "stars",
        "start"
      ],
      "success": true
    }
  ]
}
bzimmer commented 1 year ago

If the words list all have a hamming distance of 1 compared to their neighbor but they are not a guessing game the game never converges.

2023-01-09T20:46:02+01:00 DBG speculate with=["acock","kiack","clack","cacks","chack","clock","kacks","cacky","chock","click","cocks","crack","klick","kyack","chick","cocky","crock","kicks","crick","kicky","knack","knock","cleck","cluck","check","chuck","kecks","cruck","cocci","cocco"] words=["check","cheek","cheep","wheep"]
bzimmer commented 1 year ago
~/Development/src/github.com/bzimmer/qordle (speculate) > ./bin/auto-play.zsh
task: [dist] mkdir -p /Users/bzimmer/Development/src/github.com/bzimmer/qordle/dist
task: [build] go build -o /Users/bzimmer/Development/src/github.com/bzimmer/qordle/dist/qordle cmd/qordle/*.go
task: [build] go build -o /Users/bzimmer/Development/src/github.com/bzimmer/qordle/dist/qordled cmd/qordled/*.go
2023-01-10T06:48:21+01:00 INF reading from stdin
2023-01-10T06:48:24+01:00 ERR game never converged secret=mummy
2023-01-10T06:48:28+01:00 ERR game never converged secret=joker
2023-01-10T06:48:31+01:00 ERR game never converged secret=puppy
2023-01-10T06:48:35+01:00 ERR game never converged secret=belle
2023-01-10T06:48:38+01:00 ERR game never converged secret=guppy
2023-01-10T06:48:40+01:00 ERR game never converged secret=gummy
+--------+--------+---------+---------+
| secret | rounds | success | elapsed |
+--------+--------+---------+---------+
| briar  | 1      | false   | 2       |
| brawn  | 1      | false   | 2       |
| brain  | 1      | false   | 2       |
| urban  | 1      | false   | 2       |
| orbit  | 1      | false   | 2       |
| begin  | 1      | false   | 2       |
| cairn  | 1      | false   | 2       |
| brown  | 1      | false   | 2       |
+--------+--------+---------+---------+