[][src]Crate wordfeud_solver

A wordfeud library for Rust.
This crate allows you to calculate the best scores in a game of wordfeud. It can be used to study strategies in the game, or just to cheat. This library is a Rust port of the excellent wordfeudplayer python library. It can use the rayon crate to calculate moves in parallel. The time required to evaluate a board is in the order of 1 millisecond.

How to use wordfeud_solver

Start by creating a wordfeud board, then specify the wordlist to be used, and the tiles on the board. By default a standard board is used, but you can specify your own "random" board. The wordlist must be in utf-8 and contain one word per line. Several wordfeud wordlists are available on the internet. A wordlist for the dutch language is available TODO. It is based on the OpenTaal wordlist, with modifications by the author.

Basic usage

use wordfeud_solver::{Board, Letters};
use std::convert::TryFrom;

let mut board = Board::new("en").wordlist_from_words(&["rust", "rest"]);
let letters = Letters::try_from("rusta").unwrap();
let results = board.calc_all_word_scores(letters);
assert_eq!(results.len(),8);
for (x,y,horizontal,word,score) in results {
      println!("{} {} {} {} {}", x, y, horizontal, word, score);
}
board.play_word("rust", 7, 7, true, true);
println!("{}", board);

About implementation

Structs

Board

Represents the state of a wordfeud board.

Codec

Translate from string to label codes and vice versa. Each wordfeud tile is translated to a code.

Row

A wrapper around a vec of squares possibly containing tiles.

Tile

A wrapper around a (nonzero) u8 tile code.

Tiles

A wrapper around a vec of (non-empty) Tile's. Used to represent Word and Letters.

Wordlist

A trie data structure that holds all the possible words.

Enums

CodecError

Error during encoding/decoding between tiles and strings.

Type Definitions

Letters

Tiles that can be used to make a word. Can contain blanks (unassigned wildcard).

RowData

A list of 0..N (possible letters, connected) tuples.

Word

Tiles that form a word. Can contain wildcards (assigned blanks).