BPC_WordPuzzleBrain — Grid Word Solver Toolkit
A plug-and-play Actor Component for Unreal Engine 5 that solves grid-based word puzzles using recursive Depth-First Search. Drop it into any project, assign a dictionary, and start validating and solving words on any grid size.
Quick Start
Add BPC_WordPuzzleBrain to any Actor in your level.
Set GridRows and GridColumns in the Details panel to match your grid dimensions.
Assign a DictionaryTable in the Details panel.
Assign a PrefixCacheAsset in the Details panel.
Generate your board (e.g., randomize your letters) and save it as a 1D Array of Strings.
Call FindLongestWord or ValidatePath from any Blueprint, plugging your letter array into the function's input pin.
If you need to create a new dictionary or cache from scratch, see the Dictionary System section below.
Core Functions
ValidatePath
Takes your current board state (a 1D Array of Strings), a target word, and a starting index. Checks whether the target word can be traced as a valid connected path on the board. This is a board path check only — it does not perform a dictionary lookup. Wire your own dictionary check separately before or after this function depending on your game's needs.
Recommended flow: Dictionary row query → if found, call ValidatePath → award points only if both pass.
FindLongestWord
Takes your current board state (a 1D Array of Strings) and seeds a DFS from every tile on the board to return the longest valid word found. Result is stored in the LongestWord component variable.
RunSolverDFS
The recursive DFS engine called internally by FindLongestWord. Can also be called directly for custom solving logic.
CheckPathDFS
The recursive DFS engine called internally by ValidatePath. Can also be called directly for custom path validation logic.
Helper Functions
GetValidNeighbors — Returns all valid adjacent tiles for a given index.
GetXYGridCoord — Converts a flat array index to an X/Y grid coordinate.
GetCheckXY — Returns the flat index for a given X/Y coordinate.
GridToIndex — Converts a grid coordinate back to a flat array index.
IsWordCompleted — Checks whether the current DFS path spells the full target word.
DoesLetterExistOnBoard — Checks whether a given letter exists anywhere on the board.
IsCurrentTile — Confirms whether the current tile matches the expected letter.
Variables
GridRows (Integer) — Number of rows in your grid. Must match your actual grid.
GridColumns (Integer) — Number of columns in your grid. Must match your actual grid.
DictionaryTable (Data Table) — Any Data Table using S_Dictionary as its row struct. Works with any language or custom word list.
PrefixCacheAsset (PDA_PrefixCache) — The baked prefix cache corresponding to your assigned dictionary.
IterationLimit (Integer) — Max recursive calls before a forced return.
Default: 10000 — sufficient for a full 5x5 board traversal. Acts as a safeguard against infinite loops and engine crashes. Do not set to 0 or remove this check.
LongestWord (String) — Stores the result of the last FindLongestWord call.
Dictionary System
This asset is fully dictionary agnostic. Any word list can be used as long as it is formatted correctly and imported as a Data Table.
There are two assets that work together:
The Dictionary (the raw data)
Drag your CSV into the Content Browser and select S_Dictionary as the row struct. This creates your Data Table.
S_Dictionary uses two columns. The first column has no header and contains the words. The second column is titled Definition and must always be populated — use placeholder data if you do not have real definitions.
,Definition
apple,A common fruit
board,A flat piece of wood
crane,A large bird
zap,1
quest,1
Note: The first column intentionally has no header. This is required for UE5 to import the Data Table correctly using the S_Dictionary row struct. Do not add a header to the word column.
The Cache (the speed boost)
Run the BuildPrefixCache Editor Utility Actor. Point it at your Data Table. It reads the dictionary, extracts all valid prefixes, and bakes them into a PDA_PrefixCache file in your Content Browser. Assign that file to PrefixCacheAsset on the component.
The cache is read at runtime — no processing happens during play.
Included Dictionaries
DT_SOWPODS_Dictionary — Default. Full SOWPODS competitive word list. Definition column populated with placeholder data.
DT_OPTED_Dictionary — Bonus. Alternative English word list with definitions included.
DT_Dictionary_Fantasy — Example custom language list demonstrating language-agnostic design. Definitions included.
Each dictionary has a corresponding pre-built PDA_PrefixCache asset included and ready to assign.
Grid Setup
GridRows and GridColumns must match your actual grid at all times. The component uses these values to convert flat array indices to X/Y coordinates and to determine valid neighbors.
X = column, Y = row throughout the coordinate system.
There is no minimum word length enforced by design. Implement your own minimum in your game logic if needed.
Included Assets
BPC_WordPuzzleBrain — The core Actor Component.
S_Dictionary — Row struct for dictionary Data Tables.
BuildPrefixCache — Editor Utility Actor for baking prefix cache assets.
DT_SOWPODS_Dictionary — SOWPODS word list Data Table.
DT_OPTED_Dictionary — OPTED word list Data Table.
DT_Dictionary_Fantasy — Example fantasy language Data Table.
PDA_PrefixCache assets for each included dictionary.
WBP_SolverDemo — Demo widget showing recommended wiring for validation and auto-solve. Demo level, Game Mode, and Player Controller.
Demo
Open the demo level in the Demo folder and press Play. The demo runs on a randomized 5x5 letter grid.
Type any word you can trace on the board — letters must connect horizontally, vertically, or diagonally, and the same tile cannot be used twice in a single word. Hit Validate Word and the demo will tell you both whether the word exists in the active dictionary and whether it can be physically formed on the current board.
Hit Auto-Solve to find the longest word that can be formed from the current grid using the full active dictionary.
Use the combo box to switch between the included dictionaries at any time. Validate and Auto-Solve both work immediately with whichever dictionary is selected. Note that when the Fantasy dictionary is selected, the Refresh Grid button is disabled — the Fantasy board uses a fixed pre-baked grid by design.
Code Comments
Blueprint comment boxes follow a consistent color convention throughout BPC_WordPuzzleBrain:
Yellow — Safeguard logic (iteration limits, crash prevention) Red — Backtracking logic (core DFS recursion)
Documentation
Included in-editor (All setup instructions and logic explanations are thoroughly documented in the comments of the BP_README and relevant solver Blueprints). As well as replicated at the following link: https://drive.google.com/file/d/1YFIsKKZhIt31GK_KalxEXofEcQVYraw6/view?usp=sharing
Contact
For questions or support, email kyle.j.sullivan53@gmail.com with the subject line: UE5 FAB GRIDWORDSOLVER_PRO QUESTION
Please allow 1-3 business days for a response.