Presentation is loading. Please wait.

Presentation is loading. Please wait.

By: Casey Savage, Hayley Stueber, and James Olson

Similar presentations


Presentation on theme: "By: Casey Savage, Hayley Stueber, and James Olson"— Presentation transcript:

1 By: Casey Savage, Hayley Stueber, and James Olson
2048 Game Solver By: Casey Savage, Hayley Stueber, and James Olson

2 About 2048 Goal of the Game: create the 2048 tile
How to Play the Game: slide tiles left, right, up, or down to combine like numbers: For example, two adjacent 2’s can be combined to create a 4, two adjacent 4’s can make an 8, and so on. Tiles slide in the specified direction until they are stopped by a tile or the edge A new tile with the value of 2 or 4 will appear in an empty spot on the board. The player loses if there are no empty spaces left on the board.

3 Previous Work Matt Overlan: Vasilis Vryniotis:
created a code using a minimax algorithm High probability of winning, but very slow, heavily due to its animation Vasilis Vryniotis: created a problem-solver for 2048 in Java using an alpha-beta pruning algorithm Very slow and ineffective problem-solver that would not display its process. Gayas Chowdhury and Vignesh Dhamodaran Created a game solver code using Expectimax algorithm

4 Problem Statement Create a game solver that attempts to solve the game 2048 by achieving a tile while maximizing the efficiency and success rate To do this we examined: Minimax Algorithm Alpha Beta Pruning Algorithm Expectimax Algorithm

5 2048 Game tree Diagram Top Node Depth 1 Depth 2 Depth 3 …Depth (n)

6 Minimax Algorithm Has the “player” select the most effective move
Anticipates the “opponent,” or the computer, placing the next piece in the position most inconvenient for the player, but, in this case, we simply used the game’s method for placing the next tile.

7 Minimax Psuedocode function minimax(node, depth, maximizingPlayer)
if depth = 0 or node is a terminal node: return the heuristic value of node if maximizingPlayer: bestValue := -∞ For each child of node val := minimax(child, depth – 1, FALSE)) bestValue := max(bestValue, val) return bestValue else bestValue := ∞ for each child of node val := minimax(child, depth – 1, TRUE)) bestValue := min(bestValue, val) (* Initial call for maximizing player *): minimax(origin, depth, TRUE)

8 Results and Analysis of Minimax
Big O Algorithm Complexity of: O(n^d) n = number of moves in a game d = depth of the search 40% of trials fail with highest tile as 50% success rate.

9 Alpha-Beta Pruning Algorithm
An expansion of the Minimax Algorithm Main Goal: decrease the number of nodes to evaluate by comparing alpha and beta values and “pruning” sub trees

10 Alpha-Beta Pruning Pseudocode
Function alphabeta(node, depth, alpha, beta maximizingPlayer): if(max(state, α, β, depth)): If (depth ==0): return value(state) For s in Successors(state): α = MAX(α, MIN(state, α, β, depth) If α >=  β: return α else: β= MIN(β, MAX(state, α, β, depth-1) If β >= α : return β α: The best value for MAX seen so far β: The best value for MIN seen so far state: game position

11 Alpha-Beta Algorithm Results
Using a depth of 7: Success rate: 60-70% Fails at 1024 tile about 90% of the time Average Time to Solve a Game: 72 seconds Big O Algorithm Complexity of: O(n^(d/2)) n = number of moves in a game d = depth of the search

12 Expectimax Algorithm Expectimax is also a variation of minimax game tree algorithm Expectimax has chance nodes in addition to min and max, which takes the expected value of random event that is about to occur The random event being the next randomly placed 2 or 4 tile on the 2048 game board The next move sliding board Right, Left, Up, or Down is chosen by the highest expected value of all the possibilities. Expected value is calculated by weighted average of values of the children

13 Expectimax Algorithm The expectimax algorithm evaluates each node by calculating all of possible tile placements, weighted by the probability of the occurrence of each tile The percent of a 2 tile being placed is 90% and 4 tile is 10% The algorithm then chooses the case with the best probability of occurrence Depending on the set depth(d) it will calculate the probability to d amount of future moves

14 Expectimax Algorithm Pseudocode
function expectimax(node, depth, player) else if random event at node if node is a terminal node or depth = 0 // Return weighted average of all child nodes' values let α := 0 return the heuristic value of node if the adversary is to play at node α := α + (Probability[child] * expectimax(child, depth-1)) // Return value of minimum-valued child node return α let α := +∞ foreach child of node α := min(α, expectimax(child, depth-1)) else if we are to play at node // Return value of maximum-valued child node let α := -∞ α := max(α, expectimax(child, depth-1))

15 Results and Analysis of Expectimax
Expectimax Algorithm with a depth of 7 had a success rate of 80% wins The lowest tile to fail on was 1024 Reached a 4096 tile 30% of the time Big O Algorithm Complexity of: O(n^d) d = depth of the expectimax search n = number of moves in a game

16 Results And Conclusion
Expectimax proved to have the highest success rate, but had an incredibly slow runtime. Alpha-Beta pruning was less successful than expectimax, but had an incredibly quick runtime. The minimax algorithm was least effective in success rate, but quicker than expectimax.

17 Future Work Improve the Speed: Improving the speed of the algorithm will allow you to use larger depth and thus get better accuracy. Tune Heuristics: One can experiment with the way that the scores are calculated, the weights and the board characteristics that are taken into account.

18 Questions What limits a minimax algorithm?
The depth of the search What are the differences between the Minimax, Alpha Beta Pruning, and Expectimax algorithms? The Alpha Beta Pruning algorithm expands on the Minimax algorithm by eliminating branches to evaluate to hopefully decrease runtime. The Expectimax algorithm add chance nodes to the Minimax algorithm to increase the chances of getting a winning score by calculating probabilities. What is the time complexity of the Expectimax algorithm? O(n^d) As the tree depth increases, how does it affect your algorithm? It increases the likelihood of a winning outcome, but also increases the time it takes to complete.


Download ppt "By: Casey Savage, Hayley Stueber, and James Olson"

Similar presentations


Ads by Google