Presentation is loading. Please wait.

Presentation is loading. Please wait.

Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University.

Similar presentations


Presentation on theme: "Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University."— Presentation transcript:

1 Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University of York

2 English Peg Solitaire The French variant has a slightly larger board, and is considerably more difficult. 0 1 2 3 4 5 6 01234560123456 01234560123456 BeforeAfter Horizontal or vertical moves: Initial:Goal:

3 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.

4 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}.

5 Model A: IP Move Conditions: `1’ means move made. Connecting board states. Consider all moves affecting a position

6 Model A: IP One move at a time: Objective function. Minimise:

7 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

8 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. 0101 0 1 2 3 4 5 6

9 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

10 Model C Channelling Constraints These constraints closely resemble pre- and post- conditions of an AI Planning-style operator. 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

11 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.

12 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. abcabc

13 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: 11 1 1 11 111 1 11 1 11 1 1 1 1 1 1 1 1 1 1

14 Board Symmetries Rotation. Reflection. Break rotational symmetry by selecting 1 st move: Reflection symmetry persists. Remove 5,2  3,2:

15 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.

16 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.

17 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

18 Solitaire Reversals via AI Planning 13 49 - - - 148 - 14 622 - 25 121 - >1hr 47 1 - 28 0.1 125 - 42 0.15 - 16 553 - >1hr 18 >1hr 298 - 543 - 48 3544 86 - 57 - 44 0.05 313 - 17 1 - >1hr 38 0.6 27 - 30 48 - 49 0.05 60 - 27 1521 - >1hr 21 9.8 154 - 25 0.7 - 1126 862 >1hr - >1hr 14 0.05 97 >1hr 19 0.2 30 - 19 276 - 21 0.6 32 - 19 - 125 - 14 273 48 >1hr 620 >1hr 574 >1hr 16 1564 - >1hr BBox4.2 FF2.3 HSP2.0 Stan4 Bbox, FF most successful, achieve a high percentage of coverage. Note how symmetric positions differ. - memory exhausted. - >1hr - -------- >1hr --------

19 Solitaire Reversals via Model C 17 3.5 18 4.9 116 19.1 102 22,3 >1hr 337.8 >1hr 349.6 7 2.7 8 2.7 1700 197 1712 199.9 >1hr 1891.2 >1hr 1036 439 61.1 443 64.9 Basic Pair Sym Breaking Pagoda Functions Pagoda+Sym Less robust. Bad value ordering? Sym breaking, pagoda help. Blank: all >1hr 2903 221.5 2730 54.6 16 4.1 7.9 5

20 Model C + Corner Bias Value Ordering 17 3.5 18 4.9 116 19.1 102 22,3 >1hr 337.8 >1hr 349.6 7 2.7 8 2.7 1700 197 1712 199.9 >1hr 1891.2 >1hr 1036 439 61.1 443 64.9 Basic Pair Sym Breaking Pagoda Functions Pagoda+Sym 1.31.2 0.7 Taking symmetry back into account, can now cover all but one reversal Blank: all >1hr 2903 221.5 2730 54.6 16 4.1 7.9 5 1.2 0.7 4.6

21 Symmetric Paths There are often multiple ways of arriving at the same board state. Some are due to independent moves. Others are not:

22 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. DepthSolutions Found Solutions Pruned Constraints Added Time (s) 432832 <1 515722342051.5 671521504125610 72995381116167116 Total50600288187660

23 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.

24 Fool’s Solitaire: IP Model Moves, connection of board states same as model A. New objective function. Minimise: C[i,j,t]=1 iff there is a peg at position i,j with a legal move.

25 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:

26 Fool’s Solitaire: Results CP, reverse instantiation order: 20s IP, iterative approach: 27s

27 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.

28 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.

29 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.


Download ppt "Modelling and Solving English Peg Solitaire Chris Jefferson, Angela Miguel, Ian Miguel, Armagan Tarim. AI Group Department of Computer Science University."

Similar presentations


Ads by Google