~srpablo/squardle_bot

Bot to play "Squardle" https://fubargames.se/squardle/ (OCaml)
4d6ff979 — Pablo Meier 2 years ago
README and license
b9cd642b — Pablo Meier 2 years ago
oCamlfmt
87d9ba61 — Pablo Meier 2 years ago
some file reorg

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~srpablo/squardle_bot
read/write
git@git.sr.ht:~srpablo/squardle_bot

You can also use your local clone with git send-email.

#Squardle solver

This plays "Squardle," a variation of Wordle. It's… way more chaotic, with multiple colors each with multiple meanings. That said, after inputing a few words, you get the hang of it.

#How to use

Running the toplevel executable (make run), it'll ask you to input commands of the format

<guess> <row-spec> <col-spec>

Where <guess> is the word you guessed, <row-spec> is the response from the game on the input row, and <col-spec> is the response on the input column. This records the new state of the game, at which point the bot suggests the next word. So a playsession looks like this:

  • Guess your first word. I use crane. See what the game responds, notate it on the shell.

  • I hardcode the first three guesses, so I then use mould. Record the response to the bot.

  • Finally, I use fight. Record the response.

  • After that, I use whatever word the bot selects for me, and record the answer.

My last playsession looked like this:

dune build src/squardle_solver.exe
./_build/default/src/squardle_solver.exe
Good luck!
Guess + results: crane w,y1,w,r1,r1 w,r1,y1,w,o11
We suggest: cacao
Guess + results: mould b,y1,w,b,r1 b,r1,w,b,w
We suggest: deuce
Guess + results: fight b,r1,r1,y1,b b,w,w,w,b
We suggest: rider
Guess + results: rider g,g,y1,w,y1 g,w,w,r1,r1
We suggest: cacao
Guess + results: cacao y1,g,g,y1,y1 r1,y1,g,w,g
We suggest: choke
Guess + results: choke w,g,g,w,g r1,w,y1,y1,g
We suggest: rigid
Guess + results: rigid g,g,g,g,g g,w,w,w,w
We suggest: gecko
Guess + results: gecko w,g,g,w,y1 g,g,g,g,g
We suggest: deuce
Guess + results: deuce w,g,g,w,g g,o11,w,g,g
We suggest: rebus
Guess + results: rebus g,g,g,g,g g,g,g,g,g
We suggest: bacon
Guess + results: bacon g,g,g,g,g g,g,g,g,g
We suggest: dance
Guess + results: dance g,g,g,w,g g,g,g,g,g
We suggest: rebus
Guess + results: rebus g,g,g,g,g g,g,g,g,g
We suggest: gecko
Guess + results: gecko g,g,g,g,g g,g,g,g,g
We suggest: shone
Guess + results: shone g,g,g,g,g g,g,g,g,g

The input spec is documented in cli.ml, here.

#How does it work?

I'll clean up this comment sometime, but at a high level:

  • For every spot in a 5-letter word, find characters that cannot exist in a space (Black ones, White ones in your row or column, Red for columns or Yellow for rows). Create a 5-character regex with those exclusions as a character class (e.g. [^pen]), and "pin" any solved squares into place. An example generated regex might be ([^pen][^pen]av[^pen]), where the 3rd and 4th letters are av and we have black or white tiles for p and e, n. Use this regex on the valid 5-letter words to winnow it down dramatically.

  • For that winnowed-down list, "score" the guess candidate by considering:

    • Is there a Red, Yellow, or Orange character from this row or column (as appropriate) in this character spot? 3 points.
    • Is there a White tile not in this row or column, indicating this character is on the board somewhere? 1 point if so.
    • Is this already a solved character? 10 points
  • Return the highest-scoring word that isn't 50, or already solved.

#Anything else?

  • Haven't tested reproducibility — I doubt this opam file is enough to just opam install . in a new switch. Maybe later, Works On My Machine™

  • Two bugs in the modeling of gamestate: we don't grant extra turns on a solved row or column (we don't use turn number for anything yet anyway), and if your cursor lands on a solved row + col, we don't advanced to an unsolved one. You'll see me use rebus and gecko above just to advance the cursor to an unsolved row.

  • If you hit Enter with an invalid move spec, it crashes. It feels a bit brutal, but you can open a shell in a new pane and copy + paste the moves from the previous session pretty easily.

  • We don't use the number data on red, yellow, or orange at all. I suppose I could, but it's a lot more thinking/finicking than I want to invest.

Do not follow this link