How the Spider Solitaire hint works
By Spider Solitaire Online Editorial Team · Published
The hint scores every legal move using only the face-up cards, looks up to four moves ahead, and suggests the best one, or a stock deal if nothing scores well. It costs 5 points and never sees hidden cards.
The Hint button suggests a move. This page explains exactly how it chooses one, what it can and cannot see, how fast it is, and how good the resulting play is. The description matches the code in src/game/hint/hint.ts at the time of writing; if the weights below are ever changed, this page changes with them.
The one rule: only what you can see
The hint works from the same information you have. It reads the face-up cards, the number of cards left in the stock, and the rules. It never reads the face-down cards, in the tableau or the stock. That matters for two reasons. It means the hint cannot cheat you into a win by quietly knowing what is underneath. And it means the hint can be wrong in the way a person can be wrong: it may suggest a sensible move that turns over a card which makes the position worse.
Step 1: list every legal move
The engine produces every legal move in the position: each place a card or a run can go, plus the stock deal if it is allowed. Moves that would obviously accomplish nothing are removed first, such as shifting a whole column onto an empty column, which only relabels the columns. What remains is the set of candidates.
Step 2: score each move
Every candidate gets a score from a short list of features. The weights are fixed numbers:
| Feature | Points | Why |
|---|---|---|
| Completes a King-to-Ace run | +100 | Banked progress: a deal cannot bury a removed run. |
| Turns over a face-down card | +50 | New information and new options. |
| Places a card on one of its own suit | +30 | Keeps runs movable as a group. |
| Empties a column completely | +25 | An empty column is the most flexible space in the game. |
| Any legal build | +5 | A small base value so that a legal move beats nothing. |
| Breaks up an existing same-suit run | −40 | Undoing your own good work. |
| Moves part of a column into an empty column without revealing anything | −8 | Spends the empty column for no gain. |
The numbers were chosen by hand and then checked by simulation (below), not derived from theory. They express a ranking of priorities: finish runs, reveal cards, keep suits together, make empty columns, and avoid damage.
A worked example
Take the opening of the one-suit deal SS-1-7 from the first-game guide. Moving the Six from column 3 onto the Seven in column 6 turns over a hidden card (+50), lands on a card of its own suit (+30, which is always true in a one-suit game), and carries the base value (+5): 85 points. Moving the Jack from column 5 onto a Queen scores the same 85 for the same three reasons. When two moves tie, the engine keeps the one it listed first, and the lookahead adds nothing to either, because a line stops at a move that turns a card over. That is why the hint's first suggestions in this deal are a string of tied reveal moves, and why it feels so mechanical early on: in the opening, almost every good move is a reveal.
Step 3: look a few moves ahead
A move that looks quiet can open something strong next turn. So after scoring a move, the engine plays it on a copy of the position and scores the best follow-up moves, up to four moves deep. Each step further ahead counts for 70 percent of the one before it, so near-term gains outweigh speculative ones.
There are two safeguards. First, a line stops at the first move that turns over a face-down card, because from that point the position depends on a card the hint cannot know. The search never guesses it. Second, the search will not plan through junk: follow-up moves worth no more than the base value are skipped, and positions already seen in the line are not revisited.
To keep the hint quick, the search is limited to 600 positions per request. When the limit is reached the search simply stops and uses the best line found so far.
Step 4: choose between moving and dealing
The highest-scoring move wins, unless it scores only the base amount or less. In that case a stock deal is suggested instead, if dealing is allowed. If there is neither a worthwhile move nor a deal available, the hint reports that it has no helpful move. In the rare case where the only moves left would split up a run, the game shows that move only if the damage is small, and otherwise tells you there is nothing useful to do.
What it costs
Asking for a hint costs five points in standard scoring, even if you ignore the suggestion. In expert mode there is no hint button.
How fast it is
We measured the time to compute 9,199 hints during simulated games on the development machine. The median was 0.12 milliseconds, the 99th percentile was 16.7 milliseconds and the slowest single hint was 28.7 milliseconds. These are test-machine numbers. A phone will be slower, and we have not measured one, so treat the figures as an upper bound on what you will notice on a computer and not as a promise for every device.
How good is it?
We tested the hint by playing it as a robot: always take the suggestion, never undo, deal when it says deal, stop when it has nothing or the position repeats. Over 500 seeded deals for each suit count (seeds 1 to 500), it won:
| Suits | Games won | Win rate | 95% range | Runs completed on average |
|---|---|---|---|---|
| 1 | 148 of 500 | 29.6% | 25.8% to 33.7% | 4.55 |
| 2 | 2 of 500 | 0.4% | 0.1% to 1.5% | 0.14 |
| 4 | 0 of 500 | 0% | 0% to 0.8% | 0 |
This is a measure of the hint, not of the game. Some deals cannot be won by anyone, and the robot cannot undo or look at hidden cards. A human who uses the hint as one input among several does much better in principle, though we have not measured human players and make no claim about them. The detail behind these figures is on the win rates page.
What the lookahead bought
The same robot ran before the lookahead was added, when the hint scored each move on its own. It won 27.0 percent of one-suit deals and completed 4.02 runs on average, against 29.6 percent and 4.55 runs afterwards, and it won 0.2 percent of two-suit deals against 0.4 percent. Four suits stayed at zero either way. So looking ahead helps a little, mostly by completing more runs, and it does not change the picture that four suits is far harder than one.
It is worth being plain about what these tests show. The weights in the table were chosen by hand and adjusted until the robot's results improved. That makes the hint a reasonable heuristic, not an optimal player, and the numbers are specific to seeds 1 to 500.
Where the hint is weak
Because the hint is a short-sighted heuristic, its weaknesses are predictable. Knowing them lets you tell when to ignore it.
- Empty-column manoeuvres. A strong human trick is to park a card in an empty column, free the card below, and move the parked card back. That takes more than four moves to pay off, and the hint's move that uses the empty column costs it eight points, so it rarely suggests it.
- Hidden information. The hint cannot weigh what a reveal might uncover, so it treats every reveal as equally good. A human can often tell that a particular column is the one worth digging into.
- Stock timing. The hint deals when nothing else scores above the base value. It does not judge whether dealing now is better than making one more quiet move.
- Suit planning in two and four suits. The hint likes same-suit placements but has no model of which suit will be hardest to finish later.
- Long lines. Anything that needs more than four moves of preparation is invisible to it.
How it differs from the solver
Another program on this project does see the hidden cards: the solver used offline to certify winnable deals. It is allowed to know everything because its job is to answer a different question, whether a deal can be won at all. It searches far more positions than a hint would be allowed to take, and it runs ahead of time, not while you wait. The hint you use in play never has access to that information, which is why a hint on a certified deal does not walk you to the win. The page on certified deals describes the solver.
Why these design choices
Each limit exists for a reason. The hint reads only visible cards so that using it is fair and so that it behaves the same way for every player. The search is capped at 600 positions and four moves so that a hint arrives quickly, because a hint that makes the page hang is worse than none. Later moves count for less so that the hint prefers sure gains to speculative ones. And the whole thing is a single short file with fixed numbers so that its behaviour can be tested: for a given position, the same hint always comes back.
Questions about the hint
Will it ever suggest an illegal move?
No. It only chooses from the list of legal moves, and the same check that stops you breaking the rules applies to the hint.
Does it give the same answer twice?
Yes. For a given position the hint is deterministic. Ask twice without changing anything and you get the same suggestion, and you pay for each request.
Why does it sometimes suggest dealing?
Because no move on the board scored above the small base value. That is the hint's way of saying it sees nothing worth doing, which is a reasonable moment to deal. It is still worth a quick look yourself first.
Can I turn it off?
Expert mode has no hint button at all. In the other modes you simply do not press it, and it never acts on its own.
Using the hint well
The hint is best treated as a second opinion. Look at the board first, decide what you would do, then ask. If the two differ, work out why. If the hint is right, you learned a pattern; if you are right, you learned what it misses. The full advice is in using undo and hints wisely.