Download presentation
Presentation is loading. Please wait.
Published byNoreen Peters Modified over 9 years ago
1
A Fast Thinking Connect Four Machine! 6.846 Final Project Presented by Tina Wen
2
Goal Write a fast connect k game on m by n grid from scratch m n k Small m and n: exhaustive search Big m and n: search to a good depth
3
Basic Idea Negamax search (recursively call expand and combine) 241542179203452135784654321 4 459355863 433
4
Approaches 1. Sequential exhaustive search 2. One dynamic queue in shared memory (TSP) 3. Master-Slave Message Passing Tile 0 tile1 tile2 tile3 tile4 3 52 6 0 COMBINE
5
Approaches 4. Master-Slave Individually allocated shared memory (no mutex) tile0 Where to write to to distribute work? Where to get the results? tile1 From which tileReady?Result 10 20 Where to get work Ready?work 0 Where to return work? To which tilePointer 1 2 tile2 Where to get work Ready?work 0 Where to return work?
6
Heuristic Search for 4 in a row in 4 different orientations Count only rows that consist of one color and space (either red or black == 0) Out of 4:# for black # for red If one color has 4 in a row, then score =(infinity + spaces) Else score += If we are red
7
score 9 + 4 + 1 = 14 9 + 4 + 4 = 17 9 + 4 +1 = 14 score += 9 + 9 + 4 = 22 Heuristic
8
Performance Comparison (connect 3) Performance of connect 3 on 4x4 grid Number of cycles Number of processors (P) Purple: sequential no pruning
9
Performance Comparison (connect 3) Performance of connect 3 on 4x4 grid Number of cycles Number of processors (P) 0.83 Purple: sequential no pruning Red: dynamic queue
10
Performance Comparison (connect 3) Performance of connect 3 on 4x4 grid Number of cycles Number of processors (P) Purple: sequential no pruning Upper Red: dynamic queue Lower Red: message passing
11
Performance of connect 3 on 4x4 grid Number of cycles Number of processors (P) Performance Comparison (connect 3) 5.05 0.83 Purple: sequential no pruning Upper Red: dynamic queue Lower Red: message passing Blue: individually allocated shared memory
12
Performance of connect 4 on 4x4 grid Number of cycles Number of processors (P) Performance Comparison (connect 4) Purple: sequential no pruning
13
Performance of connect 4 on 4x4 grid Number of cycles Number of processors (P) Performance Comparison (connect 4) 1.15 Purple: sequential no pruning Red: dynamic queue
14
Performance of connect 4 on 4x4 grid Number of cycles Number of processors (P) Performance Comparison (connect 4) 9.59 1.15 Purple: sequential no pruning Upper Red: dynamic queue Lower Red: message passing
15
Performance of connect 4 on 4x4 grid Number of cycles Performance Comparison (connect 4) Number of processors (P) Purple: sequential no pruning Upper Red: dynamic queue Lower Red: message passing Blue: individually allocated shared memory
16
Performance of connect 4 on 4x4 grid Number of cycles Number of processors (P) Performance Comparison (connect 4) 9.87 9.59 Blue: individually allocated shared memory Red: message passing
17
Load Balancing Number of processors (P) Load balancing spread Better balanced Worse balanced 90 billion cycles 177 billion cycles 114 billion cycles 4 children 7 children
18
Sequential Pruning 2 5 <=2 >=5 Number of cyclesSequential pruningIndividually allocated shared memory (min) 3x3 connect 30.157 billion3 billion 3x3 connect 40.162 billion23 billion
19
Final Version Tile 0 Other tiles: sequential pruning Pros: Take advantage of both dynamic queue for load balancing and pruning Cons: Can’t do pruning between processors Number of cyclesSequential pruningIndividually allocated shared memory (min) Final Version (min) 3x3 connect 30.157 billion3 billion (P=50)0.069 billion (P=20) 3x3 connect 40.162 billion23 billion (P=50)0.14 billion(P=20)
20
Interactive Mode
21
Conclusion My connect four searches fast has a good heuristic By using Pruning Master slave structure Individually allocated shared memory COME TRY IT!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.