1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! A wordfeud library for Rust.
//! <br>
//! 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`](https://github.com/mrcz/Wordfeud-Player) 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 [here](https://github.com/jensanjo/wordfeud-wordlists).
//! It is based on the [`OpenTaal`](https://www.opentaal.org)
//! wordlist, with modifications by the author.
//!
//! # Basic usage
//!  ```
//! # use wordfeud_solver::{Board, Error};
//! let mut board = Board::default().with_wordlist_from_words(&["rust", "rest"])?;
//! let results = board.calc_all_word_scores("rusta")?;
//! assert_eq!(results.len(),8);
//! for s in results {
//!        println!("{} {} {} {} {}", s.x, s.y, s.horizontal, board.decode(s.word), s.score);
//!}
//! board.play_word("rust", 7, 7, true, true)?;
//! println!("{}", board);
//! # Ok::<(), Error>(())
//! ```
mod ai;
mod board;
mod error;
mod grid;
mod labelset;
mod tilebag;
mod tiles;
mod tilesets;
mod wordlist;

pub use crate::ai::{find_best_scores, Score as BestScore};
pub use crate::board::{Board, Score};
pub use crate::error::Error;
pub use crate::grid::Grid;
pub use crate::tiles::{
    Cell, Code, Codec, Item, ItemList, Label, Letter, Letters, List, Row, Tile, Word,
};
pub use crate::tilesets::Language;
pub use crate::tilesets::TileSet;
pub use crate::wordlist::{RowData, Wordlist};