Skip to main content

Lexica

Lexica power both validation and AI evaluation. Try a quick word check below, compare offline engine trade-offs, then open the full Playground to explore anagram helpers and engine swaps.

Word check (lite)
Text-based set membership (demo lexicon).
Type a word and click Check. Uses a small demo lexicon for speed.
Offline benchmark snapshot (10k words, Intel Core i9-10850K). Lower lookup/build numbers are better.
Engine
Lookup (ms)
Build (ms)
Memory (KiB)
Set
0.84
2.8
420
FST
1.21
4.3
115
DAWG
3.40
10.9
152
GADDAG
1.21
153.1
260

Engines & trade-offs

EngineUse caseNotes
setSmall demos, rapid prototypingLoads line-by-line text, O(1) membership, higher memory.
fstProduction English-sized lexicaCompact finite-state acceptance with fast prefix tests.
dawgClassic anchor/cross-check move generationMinimal edges, perfect for cross-checks.
gaddagPower-player move generation & AIStores every split permutation; fastest anchors but larger files.

You can hot-swap engines at runtime through the bindings (set_dictionary_from_text_engine or set_dictionary_from_fst_bytes) and fall back to set_free_word_mode(true) when a dictionary fails to load.

Loading dictionaries

WASM
import init, { new_game, set_dictionary_from_text_engine } from '@tiletangle/engine-wasm';

await init();
const game = new_game(JSON.stringify(cfg), 2);
await set_dictionary_from_text_engine(game, wordlist, 'fst', true);
Python
game.set_dictionary_from_words(open('twl06.txt').read().split(), case_fold=True)

For binary FST blobs, stream the bytes from storage and feed them into the bindings. The engine tracks the dictionary id (dictionary_id) alongside the current instance so persistence snapshots and cross-binding tests can confirm parity.

Lexica in AI & scoring

Hints and CPU moves rely on the same lexicon, so swapping engines changes both legality checks and AI evaluation. Pair lighter engines (set, fst) with real-time workers, or opt for gaddag when searching deep game trees. The Playground’s anagram index is a lightweight example of using lexica for UX, not just validation.

Dive deeper