Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ravneet Grewal & Joe Strathern CPSC 335 Assignment 5.

Similar presentations


Presentation on theme: "Ravneet Grewal & Joe Strathern CPSC 335 Assignment 5."— Presentation transcript:

1 Ravneet Grewal & Joe Strathern CPSC 335 Assignment 5

2 Strategy We choose a greedy algorithm strategy that had a focus on defence as opposed to offense. We felt that by focussing on defence and blocking moves that are considered threats, a slow steady offense would get five in a row more efficiently.

3 Application To implement this, we view an 11x11 grid with the center square being the opponent’s last move. We then scan the grid and assign a “danger priority” to each space based on its proximity to other moves the opponent has made. The highest priority is then made into a move.

4 Program in Use In application, our program begins well but its implementation does not always convey the proper priority for a few spaces on the grid, mainly in diagonal lines. This flaw often lead to losses.

5 Best Move Often, especially in the case of horizontal or vertical lines, our program will let them be created until it views 3 in a row, then block it successively on both sides, preventing a win. XXX O X O

6 A TIE IS NOT A LOSS Paul Adamiak T02 Aruna Meiyeppen T01

7 Strategy Check to see if we can win Check to see if opponent can win Check if we can make 4 in a row Check if opponent can make 4 in a row Make next best move root …Possible moves

8 Strategy Success The strategy didn’t work as well as hoped –Able to always beat a human user, rarely another program Defensive move is determined by a linear search of the board. –Handles a random threat which may not be the most threatening Chosen threat Most threatening

9 Favourite Move Filling space in between two threats Fill space

10 CPSC335 – Assignment 5 By: John Stuart Zach High-Leggett Tutorial #1

11 Strategy: Our strategy was a greedy algorithm which checks the board to see whether the best case scenario (being able to win) or the worst case scenario (the opponent is about to win). If either of these exist, the algorithm plays the winning move, or blocks the opponent. Otherwise, the algorithm just tries to form a line of five squares with a hierarchy of which types of moves have precedence.

12 Successes and Failures Successes: We won a single game, wherein we got 4 in a row, then were blocked, blocked our opponent's 4-in-a-row, then got five in a row.. Woot. Failures, Epic: We have not actually managed to win more than a single game (not including our opponent's disconnecting from the server).

13 Our Best Move

14 CPSC 335 -- Assignment 5: Tic-Tac-Toe Jonathan Hudson Tutorial 02

15 Strategy  Implemented a alpha-beta tree with pruning  Reasons  Supposed to allow lengthy look ahead  Which should give an advantage to decision making  Evaluation of both best opponent and current players own moves  Evaluation of board is based upon number of pieces in a five row without obstructing enemy pieces multiplied by weightings  Sum of x1's*w1+x2's*w2+x3's*w3+x4's*w4+x5's*w5  Idea was that with lookahead can determine where own player and enemy player has future wins possible

16 Performance  Both the 5 second limit and length of time to evaluate a board severly hampered strategy  5 seconds limited the depth of the tree such that the lookahead depth of tree was 2  Attempts to hash evaluation values to increase depth failed since needed custom hash table to keep them unique, (was able to hash and store but to many collisions such that incorrect evals were being returned for later queries making search control dumber resulting in many losses Monday on failed attempt)‏  Even with only the adjacent moves possibilities for a board being evaluated the longer a game runs the more states for the tree and as a result the tree starts to time out before checking all solutions  Greedy strategies can beat it since they can more completely evaluate a board, rather than the tree which loses a lot of time evaluating unecessary options and as a result tree didn't get to use its lookahead advantage in general, which made it as good as a mediocre greedy strategy (over 50% time spent evaluating multiple boards – easily improvable with an efficient precalculation of board evals and hash storage of them)‏

17 Best Move  Not easy to find a best move as all decisions are made by the algorithm there is no hard-coded human intelligence provided  The most obvious best move I guess is a result of the lookahead ability  Without some special evaluation of the board lookahead determines place to block beneficial to future moves

18 CPSC 335 A5 Presentation Team 12 Vladislav Lavrovsky and Kent Thachek Team 12 Vladislav Lavrovsky and Kent Thachek

19 = Strategy 32x32 Board 2^(32^2) = 2^1024 = No TREES! (2^1024)*16*1024 = (2^1024)*(2^14) = 2^1038 2^1038 / 2^40 (terabytes)= Almost Infinity How to prune???? 101,803,785,120,000,000,000,000,000,000,000,000,000,000,000, 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, 000,000,000,000,000,000,000,000,000,000,000,000,000 Terabytes of States! Greedy Algorithm With Heuristic Search Why?Because there is a very large game-space.

20 Strategy Do not lose! Games are won and lost in a 5x5 window! 1. Look at all subsets of windows on the board. 2. Score each axis (12 in total) for each player. 3. Compare all max scores in all reference frames for both players. 4. Logic for precedence of moves.

21 Strategy 2,0 0,0 0,10,04,00,0 0,1 0,0 0,1 786.

22 Strategy. 1 Win!

23 Sweet Moves!............................ 1... 1............... 1. 1 2............... 1 1. 2................ 1 2 2 2 1................ 2 2 1................ 1.. 2................... 2 2.................... 1....................................................... 1................... 1. 1................ 1 1. 2................ 1 2 2 2 1................ 2 2 1................ 1.. 2................... 2 2.................... 1........................... Game ~780 VS Team 13 13 wastes a move! Shazam!

24 Improvements B A Move A Move B ScoreA = 3 ScoreB = 3 Additive ScoreA = 6 Additive ScoreB = 3 Move at A! A is a more optimal move, blocks fork! But scores are equal so both moves are possible.

25 Cpsc 335 Assignment 5 David Teierle, Mark Dryden

26 Game strategy We decided to use a greedy method for choosing our moves. It allows us to efficiently determine the state of the game board and make a move accordingly. The idea behind this method is a scoring of sorts. We run both the defensive and offensive algorithms at the same time, and whichever one returns the greatest score is the move we make.

27 The plan David determined that the game could be won rather easily by creating a condition where two lines converge. This would make 2 opportunities to win, while the opponent can only block one of these opportunities. Our algorithm was designed based on this idea. As such, our defence only starts when the opponent has 3 or more in a row, at that point we block their attempts.

28 Scoring method Free move:  We can make a 3 in a row or a 4 in a row Double free:  We can make two 3 or 4 in a row lines with one move Offence  1 in row = 1  2 in row = 2  3 in row = 6  Free move = 7  Double free = 8  Win right now = 10 Defence  Under 3 in a row score = 0  3 in a row = 5  3 in a row that we have already blocked = 0  Block now, or loose the game = 9

29 Defending against our algorithm In theory the only way to defend against our algorithm would be to block every single move, which means that the opponent would have no offence. This would surly lead to a draw, at which point the player who made the first move would win. This results in a worst case win to lose ratio of 50%, which is not that bad.

30 Results Server got boned before we could finish...... We didn't really have any best move! All our moves were pure gold...

31 CPSC 335 Assignment #5 Dave Robinson (T01) Daniel Drzimotta (T02)

32 Strategy Description Utility Function - Iterates through all of our symbols placed - Checks for both runs and forks Min-Max Tree - Recursively build up a game tree with a max depth of 4

33 Strategy Evaluation Its hard to evaluate a not so functioning algorithm The min-max algorithm is considered the standard method for such 2 player games. Where it is limited, is the amount of moves ahead you can search. Using alpha beta pruning or negMax would of allowed us to create a deeper tree to search through without increasing the number to nodes to the point where the sun would explode before we found a move. Another place where we could of improved is increasing the number of possible moves we found for each node on the tree. Currently the program would take the opponents move and then find all the moves that were up to 2 spaces from it. This was another way to reduce the amount of nodes that were needed to search through. In theory this would of allowed a greater depth then finding all moves in a 32x32 playing board.

34 Best Move

35 CPSC 335 Jaeyun Noh Michael Bierkos Tutorial 2

36 Strategy used and why Greedy Algorithm! No time, too many assignments. Exam tomorrow Because we hate tracing bugs in trees…

37 Did the strategy work? Well,

38 Show your best move Well…

39 Greedy Algorithm 111 222 333 444 555 12345X54321 555 444 333 222 111

40 111 222 333 444 555 12345XO 555 444 333 222 111

41 111 232 363 484 5105 12345XO 5X5 45 54 34843 23632 12321 111

42 Greedy Algorithm 111 222 333 444 555 XO54321 X55 44 33 22 11

43 111111 223222 336333 448444 515105 12345XO54321 5X 5 45 944 3483433 2362322 1231211 111

44 Greedy Algorithm O XO X

45 CPSC 335 Assignment #5 Chad Walpole Jeff Salcedo T02

46 Strategy X O X X X X O X O O X X is our Last Move Row Right: returns -1 Diagonal RD: returns 0 Col Down: returns -1 Diagonal LD: returns 1 Row Left: returns 1 Diagonal LU: returns -1 Col Up: returns 1 Diagonal RU: returns 2 Mark Next Spot: Diagonal Right UP

47 Placement X X X X X X X X X X X O X X X X O X X X Move 1: Move 2: Move 3: Move 4: Blocked! If we get blocked then we move our marker (X) to our last move (X). And continue marking to the right.

48 Strategy Performance Worked well because we always leave a gap between our marks. Finally got it working LAST NIGHT! No animation….sorry

49 Jill Ainsworth Tim Green

50 Our Strategy Greedy Algorithm Only those spots that are adjacent to a move that has already been made Evaluate how good each of these moves is Choose the best one If there is more than one “best move” choose one of the best ones randomly

51 Did it work? Umm, not so much. In all of our test cases, it worked well, but in practice, our strategy failed to perform. Solution: we should have done more testing. Our test cases did not cover a broad enough base of possible game states. Integration testing was a problem Against others: mostly losses Against ourselves: 100% win!

52 Our best move Due to connection issues, we could not get sufficient actual data, so we look at theoretical stuff. How we evaluate a move: For each potential move, count nearby markers and potential line-length in each direction for each player Combine results into single score for that position Make move that scores highest

53 Evaluating a move... O XXXO OX OX O

54 O XXXO OX OX O

55 O XXXO OX OX O 5,1 9,1 1,0

56 Evaluating a move... O XXXO OX OX O 5,1 5,0 9,4

57 Evaluating a move... O XXXO OX OX O

58 O XXXO OX OX O

59 Our best move Due to connection issues, we could not get sufficient actual data, so we look at theoretical stuff. How we evaluate a move: For each potential move, count nearby markers and potential line-length in each direction for each player Combine results into single score for that position Make move that scores highest

60 Steven Lange Shawn Freeman April 18, 2008 Tutorial 1

61 Strategy  Our algorithm is a greedy algorithm that calculates for each square the utility value it could provide to each player.  It then adjusts the choices based on a level of aggression so that it does not prioritize defense when it can easily win.  The algorithm uses an iterative approach as a recursive approach would slow it down due to the overhead that recursion incurs.

62 Results  Our greedy algorithm was greedier than we expected.  We expected to lose more often against anyone who was using a depth first search.  Our algorithm made faster decisions than we expected.  Overall, we did better than expected.

63  Animated  Final Best Move

64 Questions?


Download ppt "Ravneet Grewal & Joe Strathern CPSC 335 Assignment 5."

Similar presentations


Ads by Google