Skip to main content

spellcast-solver

A solver for the Discord SpellCast word game. Give it a board and it finds the highest-scoring words you can spell by linking adjacent tiles.

How it works

SpellCast is a path-finding word game: you spell a word by stepping between tiles that touch (including diagonally), using each tile at most once, and you score letter values modified by bonus tiles.

The solver does a depth-first search over the board, but the key idea is that the search is guided by a trie built from the dictionary. The DFS over the grid and the descent through the trie are the same traversal:

  • Each tile you step onto follows one child edge of the current trie node.
  • If that child does not exist, no word continues down this path, so the whole branch is pruned instantly.
  • Terminal trie nodes carry the full word, so a match never has to rebuild the string it spelled.

This is both cleaner and cheaper than checking a prefix set: extending a path is an O(1) child lookup instead of rebuilding and re-hashing the prefix string at every step, and the trie shares prefixes instead of storing a separate string for each one.

Install

pip install spellcast-solver

The package bundles the public-domain ENABLE word list (~173k words), so it works with no setup. SpellCast does not publish its exact dictionary, but ENABLE is a close match. To use a different list, pass --words PATH on the CLI or load_trie(path) in code.

Usage

spellcast-solve examples/board_redeye.txt --top 10

Output is best score first, with the path and any bonuses applied:

  66  REDEYE           R(2,1) -> E(1,0) -> D(0,0) -> E(0,1) -> Y(0,2) -> E(0,3)  [long]

Board format

One row per line, whitespace-separated cells. Each cell is a letter, optionally followed by /BONUS and/or * for a gem tile. Bonus codes: DL, TL, DW, TW (or 2L, 3L, 2W, 3W). Lines starting with # are comments.

D     E/TL  Y/DW  E     E/DL
E     I/DL  C     A/DL  E
T     R/DW  K     A/TL  A/DL
A     E     G     E     B
B     S     E     W     J

Library

from spellcast_solver import Board, Solver, load_trie

board = Board.parse(open("examples/board_redeye.txt").read())
solver = Solver(board, load_trie())
moves = solver.solve()
print(moves[0].word, moves[0].score)

Scoring

  • Each letter has a fixed point value (see LETTER_VALUES in tiles.py).
  • DL / TL multiply a single tile's value by 2 / 3.
  • DW / TW multiply the whole word by 2 / 3 and stack multiplicatively.
  • Words of six letters or more get a flat +10 long-word bonus, added after the word multiplier (so the multiplier does not apply to the bonus).

Letter values are taken directly from the official SpellCast scoring table (see Sources). Any tile value can still be overridden if your board shows something different.

Development

pip install -e ".[dev]"
pytest

Sources

License

MIT, except the bundled word list (src/spellcast_solver/data/enable.txt), which is the ENABLE word list and is in the public domain.

Metadata

Release files for spellcast-solver 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spellcast-solver 1.0.1
File Size Uploaded
spellcast_solver-1.0.1.tar.gz 463.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spellcast-solver 1.0.1
File Interpreter ABI Platform
spellcast_solver-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 927.6 kB

Release files / spellcast_solver-1.0.1.tar.gz

Download URL spellcast_solver-1.0.1.tar.gz
Size 463.9 kB
Tags Source
SHA-256 checksum
How to use checksums
29437c0357ec9b9f1890b015a86af6c4cbb6197955e291a414099a96e9e009c2
BLAKE2b-256 checksum
How to use checksums
29a66662641f1c6d5b381fb92cdc7e5c83487d03ac5e68f0c57399e76aa49bcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 29, 2026.

Transparency log

Release files / spellcast_solver-1.0.1-py3-none-any.whl

Download URL spellcast_solver-1.0.1-py3-none-any.whl
Size 463.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d8a0b9566ebc2bfd51981dac63f76551bb6a978301f5ce2d3c01a06547713ab7
BLAKE2b-256 checksum
How to use checksums
a0beca2d5b23f69a6b6696413e7b35ee2a61521e2a1f918346f07dfecee8aeae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page