- Learn
- Tutorials
- Algorithms
- A* Search
- Appendices
- A Logic Reference
Appendix A — Logic Reference
Every Logic Component and Function in 8-Puzzle Solver, as it is in the finished game. Each entry stands on its own: read what it does, see what it needs, and build it from its card into your own game. A card’s Shared Variables and Per Instance Variables are the values you can change. A Shared Variable holds one value for the whole Object, under Variables in its Properties. A Per Instance Variable holds one for each placement in the Scene.
A.1 Board After Move (Function)
Built in Chapter 1, Slide the Tiles.
The Board State after the Tile in fromSlot slides into the Blank at toSlot.
- Action Name
moving- board
board- slot
fromSlot
- Value
board + moving.value * (pow(10, 8 - toSlot) - pow(10, 8 - fromSlot))
A.2 Check Goal
Built in Chapter 1, Slide the Tiles.
Says "Solved" on the Status Line when a Move, the player's or the Route's, makes the Goal, as its Tile begins to slide.
Any Object$boardState == data('Puzzle Settings', 'puzzle', 'goalBoard')- row
solved
A.3 Choose Tile (Function)
Built in Chapter 1, Slide the Tiles.
Tells Puzzle Rules which Tile was chosen: by the player's click, tap, or key, or by the Route's next Move. Puzzle Rules decides whether it moves.
- Variable
$chosenTile- Value
tile
- Applies To
puzzleRules- Custom Event
tileChosen
A.4 Click To Choose
Built in Chapter 1, Slide the Tiles.
Clicking or tapping this Tile chooses it. Puzzle Rules decides whether it moves.
Any Objectself.numberedTile- puzzleRules
@self.puzzleRules- tile
self.numberedTile.number
A.5 Hand Moves
Built in Chapter 1, Slide the Tiles.
Makes each Move on the Board State, one at a time. When a Tile beside the Blank is chosen (by the player, or by the Route), the Move is stored and every Tile is told (boardChanged); while that Tile slides, other choices are ignored. When New puzzle or Reset puts a whole Board at once (boardJumped), any slide is cut short, so choices count again.
Any Object- Action Name
chosenSlot- board
$boardState- tile
$chosenTile
- Action Name
blankSlot- board
$boardState- tile
0
- Action Name
apart- fromSlot
chosenSlot.value- toSlot
blankSlot.value
apart.value == 1- Action Name
afterMove- board
$boardState- fromSlot
chosenSlot.value- toSlot
blankSlot.value
- Variable
$boardState- Value
afterMove.value
- Event
On Tile Chosen- Mode
While Sliding
- Custom Event
boardChanged
- Event
On Tile Chosen- Mode
Ready
- Event
On Tile Chosen- Mode
Ready
A.6 Show Goal Tile
Built in Chapter 1, Slide the Tiles.
Shows one Slot of the Goal in the Goal Picture. Each Goal Cell placement sets the Slot it shows (Goal Slot). When the Goal Cell is created it moves to that Slot of the Goal Picture (Slot Position with the Board Layout row goalPicture) and shows the Tile the Goal (Puzzle Settings / goalBoard) has there; the Blank's cell shows no number and is drawn darker.
Any Objectself.goalSlot- Action Name
spot- slot
self.goalSlot.slot- layout
goalPicture
- Position Relative To
Screen- X
spot.x- Y
spot.y
- Action Name
goalTile- board
data('Puzzle Settings', 'puzzle', 'goalBoard')- slot
self.goalSlot.slot
goalTile.value > 0- Component Value
self.goalSlot.label- Value
text(goalTile.value)
- Value
'#d5c6a7'
A.7 Slide To Slot
Built in Chapter 1, Slide the Tiles.
Keeps this Tile on the Slot the Board State gives it. It jumps there when it is created and when New puzzle or Reset puts a whole Board at once (boardJumped), cutting short any slide. When a Move moves it, it slides there in a straight line at an even speed, taking slideSeconds, lands exactly on the Slot, and tells Puzzle Rules that the slide is over.
Any Objectself.numberedTileself.slideToSlotData- Custom Event
boardJumped
- Timer Name
slide
- Action Name
jumpSlot- board
$boardState- tile
self.numberedTile.number
- Action Name
jumpPlace- slot
jumpSlot.value- layout
board
- Position Relative To
Screen- X
jumpPlace.x- Y
jumpPlace.y
- Component Value
self.slideToSlotData.shownSlot- Value
jumpSlot.value
- Action Name
mySlot- board
$boardState- tile
self.numberedTile.number
mySlot.value != self.slideToSlotData.shownSlot- Component Value
self.slideToSlotData.shownSlot- Value
mySlot.value
- Action Name
place- slot
mySlot.value- layout
board
- Value
self.transform.position.x- Target
place.x- Duration
@self.slideSeconds
- Value
self.transform.position.y- Target
place.y- Duration
@self.slideSeconds
- Timer Name
slide- Repeat Every (s)
@self.slideSeconds- Ring Once
Yes
- Action Name
restingPlace- slot
self.slideToSlotData.shownSlot- layout
board
- Position Relative To
Screen- X
restingPlace.x- Y
restingPlace.y
- Applies To
@self.puzzleRules- Custom Event
slideFinished
A.8 Slot Distance (Function)
Built in Chapter 1, Slide the Tiles.
How many Moves apart two Slots are: the rows between them plus the columns between them, since a Tile never moves diagonally. Slots side by side, or one above the other, are 1 apart.
- Name
rowsApart- Value
0
- Name
columnsApart- Value
0
- Variable
rowsApart- Value
abs(floor(fromSlot / 3) - floor(toSlot / 3))
- Variable
columnsApart- Value
abs(fromSlot % 3 - toSlot % 3)
- Value
rowsApart + columnsApart
A.9 Slot Of Tile (Function)
Built in Chapter 1, Slide the Tiles.
Where one Tile is in a Board State: the Slot (0 to 8) that holds it. Tile 0 is the Blank.
- Name
slot- Value
-1
9times- Action Name
digit- board
board- slot
local.index
digit.value == tile- Variable
slot- Value
local.index
- Value
slot
A.10 Slot Position (Function)
Built in Chapter 1, Slide the Tiles.
Where one Slot of a Board drawing is on screen: the center of that Slot, from the Board Layout row named by layout ("board" for the Board, "goalPicture" for the Goal Picture). This is the only place a Slot is turned into a position.
- Name
slotX- Value
0
- Name
slotY- Value
0
- Variable
slotX- Value
data('Board Layout', layout, 'boardLeft')
- Variable
slotX- Operator
+=- Value
(slot % 3) * data('Board Layout', layout, 'slotSpacing')
- Variable
slotY- Value
data('Board Layout', layout, 'boardTop')
- Variable
slotY- Operator
-=- Value
floor(slot / 3) * data('Board Layout', layout, 'slotSpacing')
- x
slotX- y
slotY
A.11 Start Board
Built in Chapter 1, Slide the Tiles.
Sets up the Board State when the puzzle opens: the Start Board from Puzzle Settings, when it can reach the Goal (Check Start Board) and is not already the Goal. A Board that cannot, or that leaves nothing to solve, is refused: the Board opens as the Goal, and the Status Line asks for a new puzzle.
Any Object- Action Name
startCheck- board
data('Puzzle Settings', 'puzzle', 'startBoard')
startCheck.value == true && data('Puzzle Settings', 'puzzle', 'startBoard') != data('Puzzle Settings', 'puzzle', 'goalBoard')- Variable
$boardState- Value
data('Puzzle Settings', 'puzzle', 'startBoard')
- Variable
$boardState- Value
data('Puzzle Settings', 'puzzle', 'goalBoard')
- row
tryNew
A.12 Tile In Slot (Function)
Built in Chapter 1, Slide the Tiles.
Which Tile is in one Slot of a Board State: 0 for the Blank. The Board State's first digit is Slot 0 (the top-left cell) and its last digit is Slot 8.
- Value
floor(board / pow(10, 8 - slot)) % 10
A.13 Tile Keys
Built in Chapter 1, Slide the Tiles.
Keys 1 to 8 choose that Tile, the same as clicking it. A Command Event picks its Command in the Event itself, so each key has its own Event.
Any Object- puzzleRules
@self.puzzleRules- tile
1
- puzzleRules
@self.puzzleRules- tile
2
- puzzleRules
@self.puzzleRules- tile
3
- puzzleRules
@self.puzzleRules- tile
4
- puzzleRules
@self.puzzleRules- tile
5
- puzzleRules
@self.puzzleRules- tile
6
- puzzleRules
@self.puzzleRules- tile
7
- puzzleRules
@self.puzzleRules- tile
8
A.14 Add Search State (Function)
Built in Chapter 2, Step Through the Search.
Stores a Board the search has just found as a new, open Search State: its route so far (movesSoFar and parentState) and its Estimate of the Moves left. A new row starts open.
- Action Name
guess- board
board
- Action Name
addedRow- Table
"Search States"- Row
text(board)
- Table
"Search States"- Row
text(board)- Column
"movesSoFar"- Value
movesSoFar
- Table
"Search States"- Row
text(board)- Column
"estimatedMovesLeft"- Value
guess.value
- Table
"Search States"- Row
text(board)- Column
"parentState"- Value
parentState
A.15 Check Start Board (Function)
Built in Chapter 2, Step Through the Search.
Whether a Board can reach the Goal: it must hold every digit 0 to 8 exactly once, in at most nine digits, and its number of inversions (Count Inversions) and that of the Goal must be both even or both odd. A Move never changes whether the count is even or odd, so a Board that differs from the Goal there can never reach it.
- Name
missingDigits- Value
0
- Type
Boolean- Name
canReachGoal- Value
false
9times- Action Name
where- board
board- tile
local.index
where.value == (-1)- Variable
missingDigits- Operator
+=- Value
1
- Action Name
boardInversions- board
board
- Action Name
goalInversions- board
data('Puzzle Settings', 'puzzle', 'goalBoard')
missingDigits == 0 && (boardInversions.value % 2) == (goalInversions.value % 2) && board == floor(board) && board < 1000000000- Variable
canReachGoal- Value
true
- Value
canReachGoal
A.16 Count Inversions (Function)
Built in Chapter 2, Step Through the Search.
The number of inversions of a Board: pairs of Tiles where the larger number comes first in reading order. The Blank is not counted. A Move never changes whether this number is even or odd: a Tile sliding left or right keeps the reading order, and a Tile sliding up or down passes two other Tiles.
- Name
earlierSlot- Value
0
- Name
inversions- Value
0
9times- Variable
earlierSlot- Value
local.index
- Action Name
earlier- board
board- slot
earlierSlot
9times- Action Name
later- board
board- slot
local.index
local.index > earlierSlot && later.value > 0 && earlier.value > later.value- Variable
inversions- Operator
+=- Value
1
- Value
inversions
A.17 Estimate Moves Left (Function)
Built in Chapter 2, Step Through the Search.
The Estimate of the Moves still needed from a Board to the Goal, by the Estimate chosen in $estimate (a row of the Estimates table). Manhattan distance adds, for each Tile, the rows plus the columns between its Slot and its Slot in the Goal; misplaced Tiles adds 1 for each Tile out of place. The Blank is not counted. Neither guesses more Moves than are really needed, which is what lets A* find the shortest Route.
- Name
total- Value
0
- Name
tileMoves- Value
0
- Type
Boolean- Name
countsSlotsAway- Value
true
- Variable
countsSlotsAway- Value
data('Estimates', $estimate, 'countsSlotsAway')
9times- Action Name
here- board
board- slot
local.index
here.value > 0- Action Name
home- board
data('Puzzle Settings', 'puzzle', 'goalBoard')- tile
here.value
- Action Name
away- fromSlot
local.index- toSlot
home.value
- Variable
tileMoves- Value
away.value
countsSlotsAway == false && tileMoves > 0- Variable
tileMoves- Value
1
- Variable
total- Operator
+=- Value
tileMoves
- Value
total
A.18 Expand Best State (Function)
Built in Chapter 2, Step Through the Search.
One Step of the A* search: picks the best open Search State (Pick Best Open State). If it is the Goal, the Goal is accepted ("goalAccepted"); otherwise it is Expanded (Expand State). When no Search State is open, the search stops ("searchStopped"). Both messages go to Puzzle Rules.
- Action Name
best
best.found == truebest.state == data('Puzzle Settings', 'puzzle', 'goalBoard')- Applies To
puzzleRules- Custom Event
goalAccepted
- puzzleRules
puzzleRules- state
best.state
- Applies To
puzzleRules- Custom Event
searchStopped
A.19 Expand State (Function)
Built in Chapter 2, Step Through the Search.
Expands one Search State: closes it, adds it to States checked, and stores every Board one Move away (Store Neighbor). Tells Puzzle Rules "searchStopped" when a new Search State would not fit.
- Type
Boolean- Name
isFull- Value
false
- Table
"Search States"- Row
text(state)- Column
"isOpen"- Value
No
- Variable
$statesChecked- Operator
+=- Value
1
- Action Name
blank- board
state- tile
0
9times- Action Name
apart- fromSlot
local.index- toSlot
blank.value
apart.value == 1- Action Name
stored- parentState
state- parentMoves
data('Search States', text(state), 'movesSoFar')- fromSlot
local.index- blankSlot
blank.value
stored.value == true- Variable
isFull- Value
true
isFull == true- Applies To
puzzleRules- Custom Event
searchStopped
A.20 Pick Best Open State (Function)
Built in Chapter 2, Step Through the Search.
Finds the open Search State with the lowest score, movesSoFar + estimatedMovesLeft (f = g + h). On a tie, the lower estimatedMovesLeft wins; on a further tie, the one stored first. found is No when no Search State is open.
- Type
Boolean- Name
isFound- Value
false
- Name
bestState- Value
0
- Name
bestScore- Value
0
- Name
bestEstimate- Value
0
- Name
score- Value
0
- Name
estimate- Value
0
- Type
Boolean- Name
isBetter- Value
false
dataCount('Search States')timesdata('Search States', local.index, 'isOpen') == true- Variable
estimate- Value
data('Search States', local.index, 'estimatedMovesLeft')
- Variable
score- Value
data('Search States', local.index, 'movesSoFar')
- Variable
score- Operator
+=- Value
estimate
- Variable
isBetter- Value
false
isFound == false- Variable
isBetter- Value
true
score < bestScore- Variable
isBetter- Value
true
score == bestScore && estimate < bestEstimate- Variable
isBetter- Value
true
isBetter == true- Variable
isFound- Value
true
- Variable
bestState- Value
dataRow('Search States', local.index)
- Variable
bestScore- Value
score
- Variable
bestEstimate- Value
estimate
- found
isFound- state
bestState
A.21 Run Search
Built in Chapter 2, Step Through the Search.
Runs the A* solver one Step at a time, from the Board shown. Solve Timer sends takeStep for each Step. The first Step stores that Board as the first open Search State; each Step then Expands the best open Search State (Expand Best State) until the Goal is accepted (goalAccepted). Each Step then copies one record of the Route, back along the parents (Building Route), and then plays one of its Moves (Playing Route). When the search stops (searchStopped) or the Route has been played, Step has nothing more to do (Finished). A hand Move, a New puzzle or Reset, or a change of Estimate cancels the search (cancelSearch). The Status Line and the Message Line say what the solver is doing ($statusRow).
Any Objectself.runSearchData- Variable
$messageLine- Value
data('Messages', 'ready', 'explanation')
- Applies To
@self.puzzleRules- Custom Event
stepPressed
$boardState != data('Puzzle Settings', 'puzzle', 'goalBoard')- board
$boardState- movesSoFar
0- parentState
-1
- row
searching
- Variable
$messageLine- Value
data('Messages', $statusRow, 'explanation')
- Event
On Take Step- Mode
Searching
- puzzleRules
@self.puzzleRules
- Applies To
@self.puzzleRules- Custom Event
pauseSolve
- puzzleRules
@self.puzzleRules
- Action Name
copied- board
self.runSearchData.routeBoard
copied.value == (-1)- Component Value
self.runSearchData.movesPlayed- Value
0
- row
solving
- Variable
$messageLine- Value
data('Messages', $statusRow, 'explanation')
- Event
On Take Step- Mode
Playing Route
- Component Value
self.runSearchData.routeBoard- Value
copied.value
- Component Value
self.runSearchData.routeNextBoard- Value
data('Solution Route', text(self.runSearchData.movesPlayed + 1), 'state')
- Action Name
routeTile- board
$boardState- nextBoard
self.runSearchData.routeNextBoard
- puzzleRules
@self.puzzleRules- tile
routeTile.value
- Applies To
@self.puzzleRules- Custom Event
pauseSolve
- Component Value
self.runSearchData.routeBoard- Value
data('Puzzle Settings', 'puzzle', 'goalBoard')
- row
building
- Variable
$messageLine- Value
data('Messages', $statusRow, 'explanation')
- Event
On Take Step- Mode
Building Route
- row
tryNew
- Variable
$messageLine- Value
data('Messages', $statusRow, 'explanation')
- Event
On Take Step- Mode
Finished
$boardState == self.runSearchData.routeNextBoard- Component Value
self.runSearchData.movesPlayed- Operator
+=- Value
1
$boardState == data('Puzzle Settings', 'puzzle', 'goalBoard')- Variable
$messageLine- Value
data('Messages', 'solved', 'explanation')
- Event
On Take Step- Mode
Finished
- Custom Event
cancelSearch
- Table
"Search States"
- Table
"Solution Route"
- Component Value
self.runSearchData.routeNextBoard- Value
-1
- Variable
$statesChecked- Value
0
$boardState != data('Puzzle Settings', 'puzzle', 'goalBoard')- row
ready
- Variable
$messageLine- Value
data('Messages', 'ready', 'explanation')
- Event
On Take Step- Mode
Not Started
- Applies To
@self.puzzleRules- Custom Event
pauseSolve
- Custom Event
cancelSearch
- Custom Event
cancelSearch
A.22 Send When Pressed
Built in Chapter 2, Step Through the Search.
Clicking or tapping this button sends its message, a Custom Event, to Puzzle Rules. Each button placement sets its own message and its own words; a button that sets none asks for a Step (stepPressed).
Any Object- Applies To
@self.puzzleRules- Custom Event
self.message
A.23 Store Neighbor (Function)
Built in Chapter 2, Step Through the Search.
Stores the Board made by sliding the Tile in fromSlot into the Blank, reached from parentState (whose route takes parentMoves). A new Board becomes an open Search State (Add Search State); a Board stored before takes the new route only when it is shorter, and is then open again. isFull is Yes when a new Board would not fit in Search Settings / maxStates.
- Name
neighborState- Value
0
- Name
newMoves- Value
0
- Type
Boolean- Name
isFull- Value
false
- Action Name
neighbor- board
parentState- fromSlot
fromSlot- toSlot
blankSlot
- Variable
neighborState- Value
neighbor.value
- Variable
newMoves- Value
parentMoves
- Variable
newMoves- Operator
+=- Value
1
- Action Name
storedBefore- Table
"Search States"- Row
text(neighborState)
storedBefore.value == truenewMoves < data('Search States', text(neighborState), 'movesSoFar')- Table
"Search States"- Row
text(neighborState)- Column
"movesSoFar"- Value
newMoves
- Table
"Search States"- Row
text(neighborState)- Column
"parentState"- Value
parentState
- Table
"Search States"- Row
text(neighborState)- Column
"isOpen"- Value
Yes
dataCount('Search States') < data('Search Settings', 'search', 'maxStates')- board
neighborState- movesSoFar
newMoves- parentState
parentState
- Variable
isFull- Value
true
- Value
isFull
A.24 Copy Route Record (Function)
Built in Chapter 3, Trace and Replay the Route.
Copies one record of the Route: a Board on the stored route to the Goal goes into the Solution Route under its Move number, which is its movesSoFar (g) in Search States. parentState is the Board its route came from: the record to copy next, or -1 after the Board the search started from.
- Name
moveNumber- Value
0
- Variable
moveNumber- Value
data('Search States', text(board), 'movesSoFar')
- Action Name
addedRow- Table
"Solution Route"- Row
text(moveNumber)
- Table
"Solution Route"- Row
text(moveNumber)- Column
"state"- Value
board
- Value
data('Search States', text(board), 'parentState')
A.25 Tile For Move (Function)
Built in Chapter 3, Trace and Replay the Route.
Which Tile slides to turn a Board into the next Board of the Route: the Tile that sits in board where nextBoard has its Blank. In nextBoard it has slid into board's Blank.
- Action Name
nextBlank- board
nextBoard- tile
0
- Action Name
moving- board
board- slot
nextBlank.value
- Value
moving.value
A.26 Show Status Row (Function)
Built in Chapter 4, Solve and Pause.
Shows a situation on the Status Line: $statusRow becomes row, the Messages row of that situation, and the Status Line shows that row's words. While Solve is paused, Solve Timer shows the same row's pausedWords instead.
- Variable
$statusRow- Value
row
- Variable
$statusLine- Value
data('Messages', $statusRow, 'words')
A.27 Solve Timer
Built in Chapter 4, Solve and Pause.
Decides when the solver takes a Step (takeStep): once each time the player presses Step, and, while Solve runs, up to stepsPerTick Steps every solveSeconds. No Step is taken while a Tile slides, so the Route plays one slide at a time and a Step pressed during a slide does nothing. The Solve button and the A key start Solve or pause it; Escape and Step pause it, and so does the search when it has nothing more to do. Pausing keeps all progress. The Status Line shows the words of $statusRow while Solve runs, and its pausedWords while it is paused.
Any Object- Variable
$solveButtonWords- Value
data('Messages', 'solveButton', 'words')
- Custom Event
solvePressed
- Custom Event
pauseSolve
- Timer Name
solveTick- Repeat Every (s)
@self.solveSeconds
- Event
On Solve Pressed- Mode
Running
- Variable
$solveButtonWords- Value
data('Messages', 'pauseButton', 'words')
- Variable
$statusLine- Value
data('Messages', $statusRow, 'words')
- Custom Event
pauseSolve
- Custom Event
stepDue
- Custom Event
pauseSolve
@self.stepsPerTicktimes- Custom Event
stepDue
- Custom Event
takeStep
- Event
On Step Due- Mode
Tile Sliding
- Event
On Step Due- Mode
No Tile Sliding
- Event
On Step Due- Mode
No Tile Sliding
- Timer Name
solveTick
- Event
On Solve Pressed- Mode
Paused
- Variable
$solveButtonWords- Value
data('Messages', 'solveButton', 'words')
- Variable
$statusLine- Value
data('Messages', $statusRow, 'pausedWords')
A.28 Choose Estimate
Built in Chapter 5, New Puzzles and Two Estimates.
The Estimate button and the E key change the Estimate the search uses ($estimate) to the next row of the Estimates table. The search made with the old Estimate is cancelled, so both Estimates can be tried on the same Board.
Any Object- Custom Event
estimatePressed
- Variable
$estimate- Value
data('Estimates', $estimate, 'next')
- Custom Event
estimateChanged
A.29 New Puzzle
Built in Chapter 5, New Puzzles and Two Estimates.
Puts a whole Board on the table at once, without slides. New puzzle makes a Board by random legal Moves from the Goal (Scramble Board); Reset puts back the Board of the last New puzzle, or the Board the game opened with. Either way it broadcasts boardJumped, so the Tiles jump and the search starts over. When Reset puts back a Start Board that was refused (the Goal), the Status Line asks for a new puzzle again, as when the puzzle opened.
Any Objectself.newPuzzleData- Component Value
self.newPuzzleData.resetBoard- Value
$boardState
- Custom Event
newPressed
- Custom Event
resetPressed
- Action Name
scrambled
- Variable
$boardState- Value
scrambled.value
- Component Value
self.newPuzzleData.resetBoard- Value
$boardState
- Custom Event
boardJumped
- Variable
$boardState- Value
self.newPuzzleData.resetBoard
$boardState == data('Puzzle Settings', 'puzzle', 'goalBoard')- row
tryNew
- Custom Event
boardJumped
A.30 Random Move (Function)
Built in Chapter 5, New Puzzles and Two Estimates.
Makes one random legal Move on a Board: one of the Tiles beside the Blank, each with the same chance, slides into it. The Tile in notFromSlot is never chosen, so the Move just made is not undone (-1 lets every Tile beside the Blank be chosen). movedTo is the Slot the Tile slid into, where the Blank was.
- Name
choices- Value
0
- Name
counted- Value
0
- Name
fromSlot- Value
-1
- Action Name
blank- board
board- tile
0
9times- Action Name
apart- fromSlot
local.index- toSlot
blank.value
apart.value == 1 && local.index != notFromSlot- Variable
choices- Operator
+=- Value
1
- Action Name
pick- Minimum
1- Maximum
choices
counted < pick.value- Variable
fromSlot- Operator
+=- Value
1
- Action Name
apartAgain- fromSlot
fromSlot- toSlot
blank.value
apartAgain.value == 1 && fromSlot != notFromSlot- Variable
counted- Operator
+=- Value
1
- Action Name
afterMove- board
board- fromSlot
fromSlot- toSlot
blank.value
- board
afterMove.value- movedTo
blank.value
A.31 Scramble Board (Function)
Built in Chapter 5, New Puzzles and Two Estimates.
Makes a New puzzle: starts from the Goal and makes Puzzle Settings / scrambleMoves random legal Moves (Random Move), never undoing the Move just made. If that lands on the Goal, one more Move is made. A Board made by legal Moves from the Goal can always be solved.
- Name
board- Value
0
- Name
notFromSlot- Value
-1
- Variable
board- Value
data('Puzzle Settings', 'puzzle', 'goalBoard')
data('Puzzle Settings', 'puzzle', 'scrambleMoves')times- Action Name
scramble- board
board- notFromSlot
notFromSlot
- Variable
board- Value
scramble.board
- Variable
notFromSlot- Value
scramble.movedTo
board == data('Puzzle Settings', 'puzzle', 'goalBoard')- Action Name
oneMore- board
board- notFromSlot
notFromSlot
- Variable
board- Value
oneMore.board
- Value
board
