Download pptx - HPC Checkers

Transcript
Page 1: HPC Checkers

HPC Checkers ByAndy BlockRyan Egan

Page 2: HPC Checkers

Table of Contents• Overview of Checkers

▫Overview of Checkers▫Rules of the Game

• AI Theory• The Program

▫Board▫Sample Jump▫Future Moves▫Parallel Processing▫Using the Future Table

• Work in progress

Page 3: HPC Checkers

Overview of Checkers•8x8 checkered board using only the black

squares•32 positions•Search space of 5x1020

•Each Player starts with 12 men

Page 4: HPC Checkers

Rules of Checkers• Pieces

▫ Men can only move forwarded diagonally 1 space▫ Kings can move forwarded and backward diagonally 1

space▫ Upon reaching the opposite back row men become kings▫ Each player starts with 12 men

• Jumping▫ Men and kings are required to jump when possible▫ Multiple jumps are allowed and required when possible▫ When a man or king is jumped it is removed from the

board▫ If a man jumps into the back row and becomes a king the

turn is ended.

Page 5: HPC Checkers

Rules of Checkers cont.•Start Game

▫Red always moves first•End Game

▫The game ends when one player can no longer move

▫Game can end it a draw

Page 6: HPC Checkers

AI Theory•Heuristics

▫Not perusing paths that appear to not be as beneficial as other paths

▫Alpha-beta pruning •Planning

▫Future moves are calculated to generate a plan of attack that maximizes benefit and minimizes loss.

Page 7: HPC Checkers

The Program •The Board

▫Stored as 33 value integer array▫Starting board

{1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ,3,3,

3,3,3,3,5}▫Adjacency matrix used to navigate board.▫The 33rd value in the board array is used

for locations that are off the board in the Adjacency matrix.

Page 8: HPC Checkers
Page 9: HPC Checkers

The Program cont.•Jumps

▫For men jumps form a directed and acyclic graph (DAG)

▫A breadth first search is used to build a list of adjacent jumpable locations

▫Starting from the last found location the adjacency list is traversed in reverse to find the longest path.

▫This will return the greatest number of possible jumps. Issue: This may miss jumps that would have better

outcomes later on.

Page 10: HPC Checkers

Sample Jump

Enqueue Root (2)

2

{2

Page 11: HPC Checkers

Sample Jump

Look Left (9)

2

{2

Page 12: HPC Checkers

Sample Jump

Enqueue (9)

2

9

{2

Page 13: HPC Checkers

Sample Jump

Look Right

2

9

{2

Page 14: HPC Checkers

Sample Jump

Look Left (16)

2

9

{2,9},

Page 15: HPC Checkers

Sample Jump

Enqueue (16)

2

16

9

{2,9},

Page 16: HPC Checkers

Sample Jump

Look Right (18)

2

16

9

{2,9},

Page 17: HPC Checkers

Sample Jump

2

16 18

9

Enqueue (18)

{2,9},

Page 18: HPC Checkers

Sample Jump

2

16 18

9

Look Left

{2,9},{9,16},

Page 19: HPC Checkers

Sample Jump

2

16 18

9

Look Right (25)

{2,9},{9,16},

Page 20: HPC Checkers

Sample Jump

2

16 18

9

25

Enqueue (18)

{2,9},{9,16},

Page 21: HPC Checkers

Sample Jump

2

16 18

9

25

Look left

{2,9},{9,16},{9,18},

Page 22: HPC Checkers

Sample Jump

2

16 18

9

25

Look Right

{2,9},{9,16},{9,18},

Page 23: HPC Checkers

Sample Jump

2

16 18

9

25

Look Left

{2,9},{9,16},{9,18},{16,25}

Page 24: HPC Checkers

Sample Jump

2

16 18

9

25

Look Right

{2,9},{9,16},{9,18},{16,25}

Page 25: HPC Checkers

Sample Jump

2

16 18

9

25

Back to Root

{2,9},{9,16},{9,18},{16,25}

Page 26: HPC Checkers

Sample Jump

2

16 18

9

25

Back to Root

{2,9},{9,16},{9,18},{16,25}

Page 27: HPC Checkers

Sample Jump

2

16 18

9

25

Back to Root

{2,9},{9,16},{9,18},{16,25}

Page 28: HPC Checkers

Sample Jump

2

16 18

9

25

Back to Root

{2,9},{9,16},{9,18},{16,25}

Page 29: HPC Checkers

Sample Jump

2

16 18

9

25

Back to Root

{2,9},{9,16},{9,18},{16,25}

Page 30: HPC Checkers

Future Moves•For each move of player 1 each possible

move of player 2 is calculated•For each move of player 2 each possible

move of player 1 is calculated•This is repeated until a given search

depth is reached.•Very quickly this can result in very large

search area.

Page 31: HPC Checkers

Future Moves• To improve the play of the AI the benefit of possible

moves is calculated.• For each move of player 1 each possible move of

player 2 is calculated• For each move of player 2 each possible move of

player 1 is calculated• This is repeated until a given search depth is

reached.• When a given depth is reached the value of that path

is calculated.• Very quickly this can result in very large search area.

Page 32: HPC Checkers

Future Moves

For all Red

Page 33: HPC Checkers

Future Moves8 12

For all Red

{8,12}

Page 34: HPC Checkers

Future Moves8 12

For all Red

{8,12},{9,12}

9 12

Page 35: HPC Checkers

Future Moves8 12

For all Red

{8,12},{9,12},{9,13}

9 129 13

Page 36: HPC Checkers

Future Moves8 12

For all Red

{8,12},{9,12},{9,13},{10,13},

9 129 1310 13

Page 37: HPC Checkers

Future Moves8 12

For all Red

{8,12},{9,12},{9,13},{10,13},{10,14}

9 129 1310 1310 14

Page 38: HPC Checkers

Future Moves8 12

For all Red

{8,12},{9,12},{9,13},{10,13},{10,14} ,{11,14}

9 129 1310 1310 1411 14

Page 39: HPC Checkers

Future Moves8 12

For all Red

{8,12},{9,12},{9,13},{10,13},{10,14} ,{11,14}

9 129 1310 1310 1411 1411 15

Page 40: HPC Checkers

Future Moves8 12

White’s counter move

{8,12},{9,12},{9,13},{10,13},{10,14} ,{11,14},{11,15}

20 1620 1721 1721 1822 1822 1923 19

RED WHITE

Page 41: HPC Checkers

Future Moves8 12

White’s counter move

{8,12},{9,12},{9,13},{10,13},{10,14} ,{11,14},{11,15}

20 1620 1721 1721 1822 1822 1923 19

RED WHITE

Page 42: HPC Checkers

Future Moves8 12

White’s counter move

{8,12},{9,12},{9,13},{10,13},{10,14} ,{11,14},{11,15}

20 1620 1721 1721 1822 1822 1923 19

RED WHITE

Page 43: HPC Checkers

Future Moves8 12

White’s counter move

{8,12},{9,12},{9,13},{10,13},{10,14} ,{11,14},{11,15}

20 1620 1721 1721 1822 1822 1923 19

RED WHITE

Page 44: HPC Checkers

Parallel Processing

•Can‘t have player 2 waiting for player 1’s move to be completed.

•Search must be conducted in a timely manner.

•To improve performance multiple branches of the future move table are computed at the same time.

Page 45: HPC Checkers

Parallel ProcessingPlayer

1Player

2Player

2Player

2Player

2Player

2Player

2Player

2

•Each set of responses are run as a separate threads

•Each set can be computed independently of other sets of the same or greater depth as well as steps that did not directly precede it.

Page 46: HPC Checkers

P7P6P5P4P3

Parallel ProcessingPlayer

1Player

2Player

2Player

2Player

2Player

2Player

2Player

2

•This allows the task of searching for the best move to be split among multiple processors as well as multiple threads.

•This makes it well suited to being run on the cluster

P1 P2

Page 47: HPC Checkers

Using the Future Table• When a move made by player 1 or player 2 make a

path in the table no longer possible they are removed.

• The path that yields the highest possible point value is taken.

• The point value of a path is determined by multiple factors.• Jumping a man gets points• Taking a king gets more points than taking a man• Points are deducted for being jumped and losing pieces

• Point values for each move are determined by the total value of the possible paths that result.

Page 48: HPC Checkers

Work in Progress•Finish Threading•Migrate to Cluster•King jump logic

▫Requires a modification to the man jump logic

•End game detection▫Draw

If nothing changes in the future lookup within 40 moves call it a draw.

•Finalize point strategy