To make a match-3 puzzle game with AI, define what counts as a move and when the game checks the goal. An adjacent swap can spend one move and set off several clears. Let those clears finish before deciding whether the player ran out of moves. A useful first board is one where the second clear makes the difference between winning and losing.
Tile Conservatory is a fictional one-move puzzle with a goal of clearing six red leaves. Use its fixed board and refill sequence to check swaps, gravity, the goal counter and the order of the final checks.

Decide what makes a swap legal
Allow two pieces to exchange places if their cells share an edge. After a trial swap, scan rows and columns for runs of three or more identical pieces. If you find no run, put both pieces back and leave the move count and goal progress as they were. Show the rollback so the player can tell that the swap was rejected.
When a swap creates a run, spend one move and lock new swaps. Mark all cells in every run before clearing any of them. If a piece belongs to a horizontal run and a vertical run, clear and count that cell once. Then drop the survivors, refill empty spaces from above and scan again. A new match formed by that fall or refill is a cascade. Cascades spend no additional moves.

Trace a final move through two clears
Use a four-by-four board. Rows run from top to bottom and columns run from left to right, both starting at one. R is a red leaf, T is a teal wave, G is a gold sun and V is a violet bell. Start with one move, zero leaves cleared and no existing match.
Initial board
G T T V
T G R R
R R V R
V G T G
Try exchanging r1c1 and r1c2 first. The top row would read T G T V and no row or column would match. Undo the trial. The starting board, one move and zero cleared leaves should all be restored before you try the next swap.
Now exchange r3c3 and r3c4. Row three becomes R R R V, so the first three cells clear. The tiles above them fall one row. The refill queues for columns one through three are R,T, R,R and R,T, in the order used. The worked route never draws a piece for column four. When a column has several holes after gravity, give the lowest empty cell the next piece in that column's queue.
| Stage | Rows, top to bottom | Leaves cleared | Moves left |
|---|---|---|---|
| Accepted swap, before clearing | GTTV / TGRR / RRRV / VGTG | 0 | 0 |
| First clear and refill | RRRV / GTTR / TGRV / VGTG | 3 | 0 |
| Second clear and refill | TRTV / GTTR / TGRV / VGTG | 6 | 0 |
After the first refill, the three new leaves form a row at the top. They count only when the cascade removes them. After the second refill, the board has no match. Check the goal now. Six leaves have been cleared, so the puzzle ends in a win even though there are zero moves left.

Give the AI the board and the order of operations
SEELE supports starting a game project from a written idea. Give the project a small board, named piece shapes and an exact resolution order. Keep the first visuals simple enough to read at a glance, and use the fixed refill to compare board states after every clear.
Make a small original browser puzzle called Tile Conservatory.
Use four piece shapes with distinct colors: R red leaf, T teal wave,
G gold sun, V violet bell. Start with one move and a goal of six red
leaves cleared. Show moves remaining, goal progress and Restart.
Use this board, top to bottom:
GTTV
TGRR
RRVR
VGTG
Let the player select two edge-adjacent cells. A swap is accepted only
if it creates a row or column run of three or more identical pieces.
On an invalid swap, revert the board and change neither counter.
On an accepted swap, subtract one move and lock input.
Find all matched cells, count each once, and clear them together.
Add to the leaf counter only when a red leaf is removed.
Drop surviving pieces straight down in each column.
Use these refill queues in draw order: c1 R,T, c2 R,R, c3 R,T.
Draw into the lowest empty cell of each affected column first.
Repeat clear, drop and refill until there are no matches.
Check the leaf goal first, then whether zero moves remain.
Keep input locked through the settled outcome. No special tiles.
Restart restores the board, move and leaf counters, queues and input.
Use the worked swap as a deterministic fixture. If you try a different accepted swap, give its affected columns enough scripted pieces and trace that route separately. If a refill queue runs out during a fixture test, report the column and clear step so you can extend it deliberately.
Build the swap and rollback before wiring the cascade. If the board stops after clearing three leaves, give the AI the first refill snapshot from the table and ask it to rerun match detection after gravity. The brief-to-playable testing guide shows how to turn a specific discrepancy into a focused revision request.
Check the failure case by changing only the goal
Restart and repeat both swaps with the goal raised from six leaves to seven. Keep the board, refill and move budget fixed. The valid swap still spends the last move and clears six leaves through two rounds. After the final scan, the level should show one leaf still needed and a loss. That expectation applies to this route.
Watch for an early loss message in both versions. It means the move check may be running before the board settles. Use these checks to narrow down the failure.
| Test action | Expected behavior |
|---|---|
| Swap the invalid pair, r1c1 and r1c2 | Both pieces return. Moves stay at one and progress stays at zero. |
| Try another swap during the first refill | The input is ignored. The board follows the two clear stages above. |
| Wait for the last refill | The six-leaf goal shows a win. The seven-leaf goal shows a loss on this route, with one leaf still needed. |
| Restart after either result | The original board returns with one move, zero cleared leaves, and the refill queues back at the start. |
Frequently asked questions
Which matches should the first version count?
Count horizontal and vertical runs of three or more matching pieces in this design. When runs cross, gather their coordinates into one set before removing anything. That prevents the crossing tile from contributing twice. Save diagonal rules and special pieces for a later version if they fit the puzzle.
Should an invalid swap spend a move?
Keep it free in this first version. Show the swap reversing and leave the counters unchanged so players can connect the outcome to the rule. Test with an adjacent pair that makes no run, as well as a pair in cells that do not share an edge.
How do cascades count toward the goal?
Add a goal piece when it disappears in any clear caused by the accepted move. Refill only puts a piece on the board. Wait until the board settles to decide the outcome, so a cascade can finish the goal on the last move.
When should I replace a fixed refill with random pieces?
Keep a fixed refill until you can reproduce the expected clears, drops and result. When you test random pieces, keep the fixed case available for debugging. Check for boards with no legal swaps, and decide how to handle them before depending on random refill in a longer level.
Start with a board you can read by hand
Pick a goal piece, a short move limit and one swap you can trace all the way through. Use the SEELE AI Puzzle Game Maker to start from those rules. Run the same board after each change so you can tell whether a new animation, piece or objective has changed the underlying puzzle.


