Skip to content

seb-bl/scrabble-solver-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scrabble Helper

A helper that finds all words that can be played on a scrabble board, and evaluates their scores.

Note

Be aware this is just a hobby project for me, my future work on this project is quite uncertain.

Usage

Board file

The board is given as a text file where each line is a row on the board ( example at board.txt).

Tiles on the board are represented as letters in the file. Wildcard letter are in uppercase, while normal letters are in lowercase.

An empty square can be represented with an underscore or a space.

Dictionary

The words that can be played are put in a text file (with a .txt extension), one word per line (example at wwfwordlist.txt).

Tray

The letters of the tray are passed directly as argument. A wildcard is represented with a star * (for example trean*o has 6 letters and a wildcard)

Example

To show top 10 moves for the board in board.txt with trean*o in the tray:

cargo run --bin scrabble_one -- --dictionary wwfwordlist.txt --board board.txt -n 10 --tray trean*o

It outputs 10 moves:

127:  H-1  ↓, *ronate        ["pronated"]
      H-1  ↓, at*orne        ["attorned"]
      H-9  ↓, ra*onet        ["dragonet"]
      H-1  ↓, a*torne        ["attorned"]
      H-1  ↓, note*ar        ["notecard"]
      H-1  ↓, rato*ne        ["ratooned"]
      H-1  ↓, no*rate        ["nonrated"]
      H-1  ↓, *artone        ["cartoned"]
      H-1  ↓, *onrate        ["nonrated"]
124:  H-1  ↓, rat*one        ["ratooned", "rationed"]

Which means that playing the word "attorned" vertically at row H column 1 with a wildcard on 't' you get 127.

Config

The executable can accept a config to set the arguments, or modify other parameters.

An example can be found in scrabble-config.yaml.

Use the config like this:

./scrabble_one -c scrabble-config --tray trean*o

wildcards_have_multi_meaning

A parameter of the config is wildcards_have_multi_meaning. It can be set to true to relax the rule which makes a wilcard represent a fixed single letter from the moment it is played until the end.

If set to true, then a wildcard can have a different meaning for the vertical word than for the horizontal one, and change during the game. Wildcards on the board must also be represented as stars * instead of uppercase letter.

Faster dictionary loading

If you enable info logging (RUST_LOG=info), you may notice that some time is spent to prepare the words. This is because the dictionary is turned into a compressed representation that allows fast browsing with an automaton (thanks to the fst crate)

The compressed representation can be loaded directly from a file. To create such a file, use the following command:

cargo run --bin make_fst -- --input-list wwfwordlist.txt --output-fst wwfwordlist.fst

It can then be passed as dictionary file (with a .fst extension):

./scrabble_one --dictionary wwfwordlist.fst --board board.txt -n 5 --tray trean*o

I got the idea to make such a tool thanks to this post, where antoher tool is presented scala-scrabble-solver from which I copied the wwfwordlist.txt

About

Find all words playable on a scrabble board

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages