Giter Club home page Giter Club logo

scrabble-solver-rs's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.