Tell the player how many moves a disk-tower puzzle still needs from any position
A star rating or a hint button needs the best possible number of moves, but players do not stay on the neat starting position. This entry shows how to get the exact count from a half-solved tower, and how to reject positions that could never occur.
Why this works
The biggest disk decides everything: until it sits where it belongs, nothing above it can finish. Working down from the biggest, each disk either is already home or forces all smaller ones out of the way first, so the count follows without playing.
When not to use it
The count holds only for the classic rules with three pegs. With four pegs, extra helper places or another stacking rule, the best number is different and much harder to find, so a hint can mislead there.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- A diagram of every state
- 26 lines of example code with 3 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Tell the player how many moves a disk-tower puzzle still needs from any position" (read_entry disk-tower-moves-left-from-any-state) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP