modelling and solving english peg solitaire chris jefferson, angela miguel, ian miguel, armagan...
Post on 21-Dec-2015
216 views
TRANSCRIPT
![Page 1: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/1.jpg)
Modelling and SolvingEnglish Peg Solitaire
Chris Jefferson, Angela Miguel,Ian Miguel, Armagan Tarim.
AI Group
Department of Computer Science
University of York
![Page 2: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/2.jpg)
English Peg Solitaire
• The French variant has a slightly larger board, and is considerably more difficult.
0 1 2 3 4 5 6
0123456
0123456
0 1 2 3 4 5 6
Before After
• Horizontal or vertical moves:
Initial: Goal:
![Page 3: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/3.jpg)
Solitaire: Interesting Features
• A challenging search problem.
• Highly symmetric.• Symmetries of the board, symmetries of moves.
• Planning-style problem.• Not usually tackled directly with constraint
satisfaction/integer programming.
![Page 4: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/4.jpg)
Model A: IP
• 31 moves required to solve a single-peg reversal.• Exploit this in the modelling.
• bState[i,j,t] .• describes the state of the board at time-step t = 0, …, 31.
• M[i,j,t,d] . • denotes whether a move was made from location i, j at
time-step t. d in {N, S, E, W}.
![Page 5: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/5.jpg)
Model A: IP
]bState[],,,[ i,j,tEtjiM ]1bState[],,,[ ,j,tiEtjiM
]2bState[1],,,[ ,j,tiEtjiM
},,,{
],,,[],,bState[]1,,[bStateWESNd
dtjiM-tjitji
],,,2[],,,1[],,,2[],,,1[ WtjiMWtjiMEtjiMEtjiM
],,2,[],,1,[],,2,[],,1,[ NtjiMNtjiMStjiMStjiM
Move Conditions:`1’ means move made.
Connecting board states. Consider all moves affecting a position
![Page 6: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/6.jpg)
Model A: IP
One move at a time:
Bji
WtjiMEtjiMStjiMNtjiM),(
1]),,,[],,,[],,,[],,,[(
hole centre),(
),(
]31,,[
jiBji
jibState
Objective function.Minimise:
![Page 7: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/7.jpg)
Model B: CSP
• Rather than record the board state, model B records the sequence of moves required: moves[t]
• Each transition is assigned a unique number:
No. Trans. No. Trans. No. Trans.
0 2,,0 3 4,,0 6 2,,3
1 2,,2 4 4,2 7 3,,3
2 3,,2 5 2,,1 8… 4,,1
![Page 8: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/8.jpg)
Model B: CSP
• Problem constraints can be stated on moves[] alone.
• Consider transition 0: 2, , 0 at time-step t. The following must hold at time-step t-1.• There must be pegs at 2, 0 and 3, 0.• There must be a hole at 4, 0.
• Ensure by imposing constraints on moves[1..t-1]:
Drawback: many such constraints needed. Some of very large size.
),conflict(),support()pre(}31,...,1{ pppTt
][moves:][moves:][moves hihghggt
01
0 1 2 3 4 5 6
![Page 9: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/9.jpg)
Model C = A + B: CSP• Combines models A and B to remove some of
the problems of both.• Maintains: bState[i,j,t], moves[t].• Discards (A): M[], board state connection constraints.• Discards (B): Large arity constraints on moves[].
• Channelling constraints are added to maintain consistency between the two representations.• These connect bState[i,j,t], moves[t], bState[i,j,t+1].
t
bState[t]
moves[]
bState[t+1]
constrains constrains
![Page 10: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/10.jpg)
Model C Channelling Constraints
• These constraints closely resemble pre- and post-conditions of an AI Planning-style operator.
)}),(changes|][moves{(])1,,[bState],,[bState( jittjitji
)}),(pegIn|][moves{()1]1,,[bState0],,[bState( jittjitji
)}),(pegOut|][moves{()0]1,,[bState1],,[bState( jittjitji
Changes(i,j): set of transitions that change the state of i, j
pegIn(i,j): set of transitions that place a peg at i, j
pegOut(i,j): set of transitions that remove a peg from i, j
![Page 11: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/11.jpg)
Results: Central Solitaire
• Model A (IP): No solution in 12 hours.• Several alternative formulations also failed.• Reason: artificial objective function, hence no
tight bounds to exploit.
• Model B (CP): Exhausts memory.
• Model C (A+B, CP solver): 16 seconds.
• So:• Develop model C further.• Apply to other variations of Solitaire.
![Page 12: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/12.jpg)
Pagoda Functions• Used to spot dead-ends early.• Value assigned to each board position such that:
• Given positions a, b, c in a horizontal/vertical line: a+b c.
• Pagoda value of a board state:• Sum of values at positions where there is a peg.• Monotonically decreasing as moves made:
• Pagoda condition:• If pagoda value for an intermediate position is less
than that of final position, backtrack.
a b c a b c
![Page 13: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/13.jpg)
Pagoda Functions: Examples
• For a single-peg Solitaire reversal at position i, j, want pagoda functions with non-zero entries at i, j.• Otherwise no pruning.
• A rotation of one of these three gives a useful pagoda function for every board position:
1 1
1 1 1 1
1 1 1 1
1 1
1
1 1 1
1
1
1
1
1
1
1
1
1
![Page 14: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/14.jpg)
Board Symmetries
• Rotation.• Reflection.• Break rotational symmetry by selecting 1st move:
• Reflection symmetry persists. Remove 5,2 3,2:
![Page 15: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/15.jpg)
Board Symmetries• Further into the search are both broken and re-
established, depending on the moves made.
• Breaking this symmetry is a possible application for SBDS or SBDD.
![Page 16: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/16.jpg)
Symmetries of Independent Moves
• Many pairs of moves can be performed in any order without affecting the rest of the solutions.
• Two transitions are independent iff:• The set of pegs upon which they operate do not intersect.
• Break this symmetry by ordering adjacent entries in moves[]:• independent(moves[i], moves[i+1])
moves[i] moves[i+1]
• This problem extends to larger sets of transitions.• If 2 is independent of {3, 1}, can have 2, 3, 1 and 3, 1, 2.
![Page 17: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/17.jpg)
Results: Solitaire Reversals• Compared Model C against state of the art AI
planning systems:• Blackbox 4.2, FastForward 2.3, HSP 2.0, and Stan 4.
• Experiments on the full set of single-peg reversals.• Although many board positions symmetrical, these
positions are distinguished by the transition ordering.• Transitions chosen in ascending order.
No. Trans. No. Trans. No. Trans.
0 2,,0 3 4,,0 6 2,,3
1 2,,2 4 4,2 7 3,,3
2 3,,2 5 2,,1 8… 4,,1
![Page 18: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/18.jpg)
Solitaire Reversals via AI Planning1349--
--
148-
14622
--
25121
->1hr
471--
280.1125
-42
0.15--
16553
->1hr
18>1hr298
-
543---
483544
86---
57-
440.05313
-
171-
>1hr380.627-
3048--
490.0560-
271521
->1hr
219.8154
-
250.7-
1126862
>1hr-
>1hr14
0.0597
>1hr
190.230-
19276
--
210.632-
19-
125-
1427348
>1hr620
>1hr574
>1hr16
1564-
>1hr
BBox4.2FF2.3
HSP2.0Stan4
Bbox, FF most successful, achieve a high percentage of coverage.
Note howsymmetricpositions
differ.
- memory exhausted.
->1hr
--
----
---
>1hr----
![Page 19: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/19.jpg)
Solitaire Reversals via Model C
173.5184.911619.110222,3
>1hr337.8>1hr349.6
72.78
2.71700197
1712199.9
>1hr1891.2>1hr1036
43961.144364.9
BasicPair Sym BreakingPagoda Functions
Pagoda+Sym
Less robust. Bad valueordering?Sym breaking, pagodahelp.
Blank: all >1hr
2903221.5273054.6
164.17.95
![Page 20: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/20.jpg)
Model C + Corner Bias Value Ordering
173.5184.9
11619.110222,3
>1hr337.8>1hr349.6
72.782.7
1700197
1712199.9
>1hr1891.2>1hr1036
43961.144364.9
BasicPair Sym BreakingPagoda Functions
Pagoda+Sym
1.31.2
0.7
Taking symmetry backinto account, can nowcover all but one reversal
Blank: all >1hr
2903221.5273054.6
164.17.95
1.2
0.7
4.6
![Page 21: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/21.jpg)
Symmetric Paths
• There are often multiple ways of arriving at the same board state.
• Some are due to independent moves. Others are not:
![Page 22: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/22.jpg)
Symmetric Paths• Find all solutions to a given depth.• Group the transition sequences that lead to identical
positions.• Insert constraints that allow one representative per group.
Depth Solutions Found
SolutionsPruned
Constraints Added
Time (s)
4 328 32 32 <1
5 1572 234 205 1.5
6 7152 1504 1256 10
7 29953 8111 6167 116
Total 50600 28818 7660
![Page 23: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/23.jpg)
Fool’s Solitaire
• An optimisation variant.• Reach a position where no further moves are
possible in the shortest sequence of moves.• Not easily stated as an AI planning problem.• Shows the flexibility of the CP and IP approaches.
![Page 24: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/24.jpg)
Fool’s Solitaire: IP Model• Moves, connection of board states same as model A.
1],2,[bState],1,[bState],,[bState],,[ tjitjitjitjiC1],2,[bState],1,[bState],,[bState],,[ tjitjitjitjiC
1],,2[bState],,1[bState],,[bState],,[ tjitjitjitjiC1],,2[bState],,1[bState],,[bState],,[ tjitjitjitjiC
New objective function.Minimise:
Bji t
t tjiC),(
31
1
1 ],,[33
C[i,j,t]=1 iff there is a peg at position i,j with a legal move.
![Page 25: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/25.jpg)
Fool’s Solitaire: CP Model
• Modified version of model C.• An extra transition, deadEnd, is added to the
domain of the moves[] variables.• Assigned when no other move is possible.
• deadEnd transition is only allowed when no other transitions are possible.• Preconditions based on bState[].
• If deadEnd at moves[t], then also at all following time-steps:
deadEnd]1[movesdeadEnd][moves:}30,...,1{ ttt
![Page 26: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/26.jpg)
Fool’s Solitaire: Results
• CP, reverse instantiation order: 20s
• IP, iterative approach: 27s
![Page 27: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/27.jpg)
Conclusions
• Basic, and ineffective CP and IP models combined into a superior CP model.
• Another instance of the utility of channelling between two complementary models.
• Each allows easy statement of different aspects of the problem:• Model A: preconditions on state changes without
considering entire move history.• Model B: one move at once, combines 3 state changes
into a single token.
![Page 28: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/28.jpg)
Conclusions
• Encouraging results versus dedicated AI planning systems.
• Lessons learned should generalise to other sequential planning-style problems.• Channelling constraints specify action pre- and
post-conditions.• Breaking symmetry of independent
actions/paths.
![Page 29: Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University](https://reader035.vdocuments.site/reader035/viewer/2022062714/56649d565503460f94a34ce4/html5/thumbnails/29.jpg)
Future Work
• Further configurations of English Solitaire.• Other optimisation variants:
• Minimise number of draughts-like multiple moves using a single peg.
• Proving unsolvability.• Large search space to explore.• Will need improved symmetry breaking.
• French Solitaire.