Presentation is loading. Please wait.

Presentation is loading. Please wait.

Search in OOXX Games J.-S. Roger Jang (張智星) MIR Lab, CSIE Dept.

Similar presentations


Presentation on theme: "Search in OOXX Games J.-S. Roger Jang (張智星) MIR Lab, CSIE Dept."— Presentation transcript:

1 Search in OOXX Games J.-S. Roger Jang (張智星) MIR Lab, CSIE Dept.
National Taiwan University 2018/11/19

2 Introduction to OOXX Games (井井井井字棋)
OOXX Games (井井井井字棋 or 井4字棋) Invented by Adrien Wu (吳聖福) in 2018 Rules Two players, O and X, alternately place two tokens of their own, on a 5X5 board. O always plays first to put two O’s on the board. X always plays second to put two X’s on the board. After 11 plays, the game is ended by putting the last 3 X’s to make the board full. How to determine the winner One point for a player is achieved if we have at least 4 tokens of this player in each of the 5 rows, 5 columns, and 2 diagonals. The player with more points wins the game.

3 An Example of OOXX Game Result O: 4, X: 3  O wins!

4 Problem Definition Given a half-filled board, determine who is the winner (or a tie) if both adopt the best strategy to play. Three possible results O win X win Draw

5 Examples of Best Strategy (1/3)
Next play by O Both O and X have a score of 3 O cannot score any more  No way for O to win The best bet for O is to take the gray positions, which leads to a tie. If O didn’t choose the gray positions, X will win. So the best strategy for O is the above two gray positions.

6 Examples of Best Strategy (2/3)
Next play by O The best bet for O to score 3 is to take the gray positions X can get an addition score by take the yellow position. No matter how O play, s/he will lose the game. So the best strategy for O is actually any two positions (since s/he will lost the game anyway).

7 Examples of Best Strategy (3/3)
Next play by X If X takes the gray positions (which leads to the board in the previous slide), s/he will win. If X takes the positions marked with *, s/he will win too. So the best strategy for X is not unique.

8 Hint: How to Determine the Result?
Given a current half-filled board, search for the next possible board and record its result. Suppose the current board is O’s move, s/he will adopt the best strategy to determine the result of the current board: If any of the next boards is “O win”  “O win” Else if any of the next boards is “Draw”  “Draw” Else  “X win”

9 Hint: How to Speed Up Computation?
During the search, it is likely that you run into a board that has been computed before. You can use <unordered_map> to record the result of a given board, so you can easily retrieve it later.

10 Hint: How to Save Memory?
Each board has 25 elements, and each element has 3 states (O, X, and empty)  Use 2 bits for each element  Use a long long (64 bits) for a board to save it to an unordered map

11 … … … … Game Tree O X O win O win O X C 2 7 =21 O X C 2 5 =10 X win
Draw O win O win O X C 2 7 =21 X win X win X win X win X win X win Draw O win O X C 2 5 =10

12 Hint: How to Speed Up More?
Comments from 吳聖福

13 MinMax Rule: Game Tree of Tic-Tac-Toc
O’s move! 1: O wins 0: Draw -1: O loses X X O Max O X O -1 -1 X’s move! X X O X X O X X O Min O O O O O X O X O O X O 1 -1 -1 1 X X O X X O X X O X X O X X O X X O Max O O X O O X O O X X O O O O X O X O X X O O X O O X O X O X 1 1 X X O X X O X X O X X O Min O O X O O O O O X O O O X O O X O X X O O X O X

14 Example: a-b Pruning in a Game Tree (1/3)
Source Max Min Max Min 8 7 3 9 9 8 2 4 1 8 8 9 9 9 3 4

15 Example: a-b Pruning in a Game Tree (2/3)
Source Max Min Max Min 3 17 2 12 15 25 2 5 3 2 14

16 Example: a-b Pruning in a Game Tree (3/3)
Source

17 Exercise 1: a-b Pruning in a Game Tree
Display how the search can be reduced via a-b Pruning Max Min Max Min 5 7 3 9 6 5 2 4 1 8 1 6 4 9 3 4

18 Exercise 2: a-b Pruning in a Game Tree
Display how the search can be reduced via a-b Pruning Max Min Max Min 8 7 3 9 2 5 5 4 1 8 6 1 4 9 3 4


Download ppt "Search in OOXX Games J.-S. Roger Jang (張智星) MIR Lab, CSIE Dept."

Similar presentations


Ads by Google