Presentation is loading. Please wait.

Presentation is loading. Please wait.

C nnect 4 Group 9-18 See Zhuo Rui Jorelle 3S3 (Leader)

Similar presentations


Presentation on theme: "C nnect 4 Group 9-18 See Zhuo Rui Jorelle 3S3 (Leader)"— Presentation transcript:

1

2 C nnect 4 Group 9-18 See Zhuo Rui Jorelle 3S3 (Leader)
Leom Sheng Teng 3S2 Hrithik Victor Sekhri 3S2

3 Contents Recap Objective 2 Objective 1 Preview Introduction Objectives
Terminology Objective 1 Methodology Findings Objective 2 Methodology Findings Preview Objective 3 Web report

4 Introduction Connect 4 is a two-player, zero-sum game, in which each player alternately drop pieces to the bottom of a 7 by 6 grid. The first player to connect four pieces either horizontally, vertically or diagonally is the victor. Zero-sum - One person’s gain is equivalent to another person’s loss

5 Objectives To derive a set of heuristic rules for Connect 4 for both players, which will help them determine their next move. To find out if our heuristic rules for Connect 4 apply to different variations of the game in which the number of discs required to be connected to win, and the dimensions of the board are altered. To derive a set of heuristic rules for each variation of the game and deduce the results when both players play perfectly, using a knowledge-based approach. Knowledge-based approach - A general method of investigation or inquiry, which utilises known concepts in a given area.

6 Terminology Block Play follow up Greedy algorithm Perfect Play
Move made to temporarily prevent opponent from connecting four in a row Play follow up Play in the same column as the opponent Greedy algorithm Play that makes the most optimal moves Perfect Play A scenario where both players make the most optimal moves Odd/Even Threat A threat which is classified based on whether the row number that it is found in is odd or even Threat A generalised term for a cell that a player may occupy to form a four in a row

7 Objective 1 How to win the game?

8 Game tree In order to test our heuristic rules, we played many games with the AI. Our algorithm had a success rate of above 80% against the AI, even in Advanced difficulty. The picture shows one of the game trees we recorded for easy analysis. We played as player 1. This particular example is identical to one of the perfect play we saw in our literature review.

9 Mapping From the work by Allis (1988), we know that there are 69 ways to form a four-in-a-row. The given map shows the number of four-in-a- rows each cell can be part of. This allows us to easily evaluate the value of each cell. We identified the six cells in the middle to be the most important, as they are part of the most four-in-a-rows. Prepare the relevant Literature review slide

10 Scoring system Through the use of the map, we were able to make general judgements on who was winning the game. We devised a scoring system, whereby the score is the sum of the value of the cells occupied by the player.

11 Scoring system By subtracting our opponents’ score from our score, we get the net score. When our net score is positive, chances are that we are winning.

12 General rules Before the game, try to start first.
When there is a winning move, make it. When your opponent has directly playable threat, block it. When your opponent makes two-in-a-row either horizontally or diagonally (minor threat), block it. Do not play directly below your opponent’s threats. Do not establish threats above your opponent’s threats. Do not play directly below your own threats.

13 But what happens when none of these rules can be applied?

14 Greedy algorithm An algorithm that follows the problem solving heuristic of making the locally optimal choice (filling cell with the greatest value) at each stage with the hope of finding a global optimum (winning the game). This includes starting in the centre on the first turn. However, it is important that we take into account the changing value of cells throughout the game as a result of opponent blocks.

15 Combinatorial gameplay
Used alongside greedy algorithm In summary, this means establishing threats whenever possible. The table below shows the priority of threats. Stacked Horizontal Diagonal Vertical Most advantageous Least advantageous

16 “Goodness” of threat 1st player 2nd player Odd threat Even Threat
1st Player Wins Draw 2nd Player Wins

17 Play follow up Best method to “play out the game” after establishment of two useful threats (1st player: 2 odd threats, 2nd player: 2 even threats) Ensures that late in the game, your opponent is forced into a Zugzwang (has no choice but to play directly under one of your threats as all the other cells have been filled up, allowing you to form four-in-a-row and win.

18 Heuristic rules for Connect 4
Are none of the rules applicable in your current situation? Follow General rules Greedy Algorithm + Combinatorial Gameplay Are you first or second player? First Second Established 1 odd threats? Established 1 even threats? Play follow up Yes No

19 Combinatorial gameplay
General rules Greedy Algorithm Combinatorial gameplay Play follow up + VICTORY

20 Objective 2 Does it apply again?

21 Methodology Our methodology for Objective 2 is similar to our methodology for Objective 1, except that we analysed the different variations of the game to see how our heuristic rules can be applied. Our findings show the heuristic rules that cannot be applied to the different variations of the game and the reasoning behind it.

22 Connect 3: (5 by 4), (6 by 5) or (7 by 6)
General rules When your opponent makes two-in-a-row either horizontally or diagonally (minor threat), block it. Allowing your opponent to make two-in-a-row and establish two threats will cause you to lose the game. Greedy algorithm Due to the ease of forming three-in-a-row, the value of the cells can be disregarded when establishing threats. “Goodness” of threat Similarly, the oddness or evenness of threats can be disregarded.

23 Connect 4: (5 by 4) All of our heuristic rules apply! SUCCESS

24 Connect 4: (6 by 5) “Goodness” of threat
Establishing odd threats does not ensure victory for the first player. Similarly, establishing even threats does not ensure victory for the second player.

25 Connect 5: (5 by 4) General rules Greedy algorithm
When your opponent makes two-in-a-row either horizontally or diagonally (minor threat), block it. Just making two-in-a-row is too trivial a threat considering the need to make five-in-a-row. Greedy algorithm The value of all the cells are the same, hence it is not applicable.

26 Connect 5: (6 by 5) General rules Greedy algorithm
When your opponent makes two-in-a-row either horizontally or diagonally (minor threat), block it. Just making two-in-a-row is too trivial a threat considering the need to make five-in-a-row. Greedy algorithm With the focus on filling cells with greater value rather than on establishing threats, a five-in-a-row may be difficult to form. This is because a 6 by 5 dimension board is relatively small for Connect 5.

27 Connect 5: (6 by 5) “Goodness” of threat
Establishing odd threats does not ensure victory for the first player. Similarly, establishing even threats does not ensure victory for the second player.

28 Connect 5: (7 by 6) General rules
When your opponent makes two-in-a-row either horizontally or diagonally (minor threat), block it. Just making two-in-a-row is too trivial a threat considering the need to make five-in-a-row.

29 Conclusion Connect 3 Connect 4 Connect 5 5 by 4 General rules
Greedy algorithm “Goodness” of threat “Goodness” of threats 6 by 5 7 by 6 Pattern Identified: “Goodness” of threats can be applied as long as oddness and evenness of dimensions of the board remain the same.

30 Connect 4 Connect 5 Connect 3 Objective 3
To derive a set of heuristic rules for each variation of the game and deduce the results when both players play perfectly, using a knowledge-based approach. Connect 3 Connect 4 Connect 5

31 References Allis, V. (1988). A Knowledge-based Approach of Connect-Four. Retrieved on 16 February 2015 from trier.de/~fernau/DSL0607/Masterthesis-Viergewinnt.pdf Allen, J. D. (1990). Expert Play in Connect-Four. Retrieved on 2 March 2015 from Tromp, J. (2008). John’s Connect Four Playground. Retrieved on 8 March 2015 from

32 Web report

33 Thank You


Download ppt "C nnect 4 Group 9-18 See Zhuo Rui Jorelle 3S3 (Leader)"

Similar presentations


Ads by Google