Jurnal Ilmiah Komputer dan Informatika KOMPUTA
Edisi. .. Volume. .., Bulan 20.. ISSN : 2089-9033
if g β then
upperBound := g else
lowerBound := g return
g
Figure 3 Psuedo Code MTDf Algorithm Algorithm MTDf calling Alpha Beta function
many times by the method of zero-Alpha-Beta search window, unlike Negascout that uses wide-window
search. Dialing Alpha Beta returns the limit of the value of evaluation Minimax. Limit of the value is
then stored in the upperbound upper limit and lowerbound lower limit, forming an interval that
covers the actual value of Minimax in search of a particular depth. Positive and negative infinity
stands for values outside the interval on the leaves of trees. When the upper limit and lower limit of the
same value or lower limit value has exceeded the upper limit, then the value of Minimax has been
found.
Figure 4 MTDF Searching Tree
2. THE CONTENT OF RESEARCH
2.1 Problem Analysis
Based on research conducted by Stephen Bandung Institute of Technology applying greedy
algorithm and backtracking in the game in 2048 [2] and Vasilis Vryniotis that implement the algorithm
minimax on a game in 2048 [3], it was found that the greedy algorithm less than optimal in completing
the game in 2048 because of 11 times trial can not get the numbers in 2048, but quickly in taking the
step while backtracking algorithm can finish the game in 2048 in the first time trial but with a time of
23 minutes 18 seconds. For minimax algorithm results are determined from the depths in the search,
the more in looking the more likely to be able to complete the game in 2048, but it took much longer
appropriate depth search. It required a study of other algorithms to complete the game in 2048.
2.2 Analysis of The 2048 Game
The 2048 game is a game played alone. In this final game will be done by an algorithm that will be
examined, namely MTD f to determine a solution in resolving permaian 2048. 2048 Games played by
sliding to the left, right, top and bottom. The game ends when no boxes that can be shifted or merged
again. The game will be won when it managed to get a box that is worth 2048. Randomly number 2 or 4
will appear when it is shifted. If there was a box of equal value and its position adjacent the value can
be combined. Entries for opponents enter the data in the form of figures 2 and 4 with the possibility of
appearing to number 2 is 90 and the number 4 is 10. As for the players enter the data in the form of
direction to pan left, right, top and bottom. If one direction can not be moved so the application will
not respond and the game board unchanged.
2.3 Value Evaluation
The evaluation value to the game in 2048 on research by snaking tactic [1] which can be
calculated by the number of linear value on the board multiplied by the value of the geometric
sequence with ratio 1. It can also be written as follows:
1 ∑
2
Figure 5 Snaking Tactic
2.4 Analysis of MTDf Algorithm
In this section we will discuss about the completion of the game in 2048 using the algorithm
MTD f. 2048 The game is played on a game board with the size 4x4 box so the total is 16. The game
board is represented by a 4x4 matrix.
0,0 0,1
0,2 0,3
1,0 1,1
1,2 1,3
2,0 2,1
2,2 2,3
3,0 3,1
3,2 3,3
Figure 6 Board Game Matriks MTDf algorithm would be implemented as a
player that will maximize scores. Algorithm MTD f algorithm call Alphabeta pruning in the search for a
solution.
1024 512 256 128 2
8 4 128
4 4
2 2
16
Figure 7 The Initial State Board Game
Jurnal Ilmiah Komputer dan Informatika KOMPUTA
Edisi. .. Volume. .., Bulan 20.. ISSN : 2089-9033
Then look for the next step by using an algorithm MTDf to obtain an evaluation value of each step.
Each step has been sought can be seen in the following table:
Table 1 Left Step Search Results
Iteration G
Beta Lowerbound
Upperbound
1 -
∞ +∞
1170,5 1170,5
+∞ 2
1170,5 1171,5
1170,5 +∞
1172 1171,5
1172 +∞
3 1172
1172,5 1172
+∞ 1172
1172,5 1172,5
1172
Table 2 Right Step Search Results
Iteration G
Beta Lowerbound
Upperbound
1 -
∞ +∞
1170,5 1170,5
+∞ 2
1170,5 1171,5
1170,5 +∞
1172 1171,5
1172 +∞
3 1172
1172,5 1172
+∞ 1172
1172,5 1172,5
1172
Table 3 Up Step Search Results
Iteration G
Beta Lowerbound
Upperbound
1 -
∞ +∞
1184 1184
+∞ 2
1184 1185
1184 +∞
1184 1185
1184 1184
Table 4 Down Step Search Results
Iteration G
Beta Lowerbound
Upperbound
1 -
∞ +∞
1025 1025
+∞ 2
1025 1026
1025 +∞
1172 1026
1172 +∞
3 1172
1173 1172
+∞ 1172
1173 1172
1172
In the above table have been searching algorithms using MTDf. Variable G is the value of a function
call Alphabeta search, variable beta beta value at the MTD f to the value upperbound on the function
of the alphabet, while lowerbound and upperbound is the upper limit and lower limit of the algorithm
MTD f in the search. Then each displacement value obtained as follows: Left = 1172, 1172 =
Right, Up and Down = 1184 = 1172. From the results obtained that the next step is to up.
2.5 Testing System Testing algorithm is performed to test the accuracy
and speed of the algorithm MTD f which has been implemented in 2048. The game 2048 game will be
played by the algorithm MTD f as many as 10 times each search depth level. Then count the
number of games that could be reached in 2048 at each level of the depth of the search. So as to get the
accuracy of the algorithm MTD f by comparing the number of games that could be reached in 2048 with
the number of games that have been made. Search will be made until a greater degree of accuracy
equal to 50. As for the speed is calculated based on the time required to complete the game in 2048.
Table 5 Results of Testing Depth Level 0
Trial Status
Largest Tile
Time HH:mm:ss.SSS
Skor
1 Failed
256 00:00:05.627
3368 2
Failed 256
00:00:05.452 3236
3 Failed
128 00:00:04.053
1932 4
Failed 256
00:00:04.695 2632
5 Failed
512 00:00:07.212
5184 6
Failed 64
00:00:01.734 668
7 Failed
256 00:00:05.787
3472 8
Failed 256
00:00:05.761 3364
9 Failed
256 00:00:06.370
3884 10
Failed 128
00:00:03.698 1796
Table 6 Results of Testing Depth Level 1
Trial Status
Largest Tile
Time HH:mm:ss.SSS
Score
1 Failed
512 00:00:10.845
8548 2
Failed 256
00:00:04.725 2928
3 Failed
256 00:00:05.151
3140 4
Failed 512
00:00:09.751 7108
5 Failed
256 00:00:06.577
4200 6
Failed 512
00:00:08.955 6580
7 Failed
128 00:00:02.640
1292 8
Failed 512
00:00:08.136 5728
9 Failed
256 00:00:07.661
5012 10
Failed 128
00:00:02.824 1380
Table 7 Results of Testing Depth Level 2
Trial Status
Largest Tile
Time HH:mm:ss.SSS
Score
1 Failed
1024 00:07:50.290
16404 2
Failed 1024
00:06:03.666 12588
3 Failed
512 00:01:45.126
9352 4
Failed 1024
00:04:01.744 14824
5 Failed
512 00:00:46.471
7272 6
Failed 512
00:01:18.127 8092
7 Failed
1024 00:06:11.310
16848 8
Failed 1024
00:08:14.355 18380
9 Failed
512 00:01:49.780
9204 10
Failed 512
00:01:10.856 7464
Table 8 Results of Testing Depth Level 3
Trial Status
Largest Tile
Time HH:mm:ss.SSS
Score
1 Succeed
2048 00:15:20.262
24508 2
Failed 1024
00:10:42.021 17788
3 Failed
1024 00:11:36.187
16476 4
Failed 1024
00:15:19.595 9552
5 Succeed
2048 00:26:19.731
20176 6
Failed 1024
00:09:35.158 15620
7 Failed
512 00:07:35.641
8780 8
Failed 1024
00:12:23.831 12456
9 Failed
1024 00:12:21.244
12492 10
Failed 512
00:09:37.873 7968
Table 9 Results of Testing Depth Level 4
Trial Status
Largest Tile
Time HH:mm:ss.SSS
Score
1 Failed
1024 00:31:49.967
16160 2
Failed 1024
00:28:05.387 17748
3 Failed
1024 00:39:40.811
12252 4
Succeed 2048
00:43:53.370 20168
5 Failed
1024 00:36:10.246
14040 6
Succeed 2048
00:33:54.834 20256