The Fifteen Puzzle- A New Approach through Hybridizing Three Heuristics Methods

Fifteen Puzzle problem is one of the most classical problems that have captivated mathematical enthusiasts for centuries. This is mainly because of the huge size of the state space with approximately 1013 states that have to be explored and several algorithms have been applied to solve the Fifteen Puzzle instances. In this paper, to deal with this large state space, Bidirectional A* (BA*) search algorithm with three heuristics, such as Manhattan distance (MD), linear conflict (LC), and walking distance (WD) has been used to solve the Fifteen Puzzle problems. The three mentioned heuristics will be hybridized in a way that can dramatically reduce the number of generated states by the algorithm. Moreover, all those heuristics require only 25KB of storage but help the algorithm effectively reduce the number of generated states and expand fewer nodes. Our implementation of BA* search can significantly reduce the space complexity, and guarantee either optimal or near-optimal solutions.1


Introduction
The Fifteen Puzzle is a standard sliding puzzle invented by Samuel Loyd in the 1870s [1], which consists of 15 tiles with one tile missing within a 4x4 grid. The fifteen tiles numbered from 1 to 15. The numbered tiles should be initially ordered randomly. This game aims to slide those tiles, which are located next to the space into the space (one at a time) to get the numerical order of the tiles from left to right with the blank at the bottom right/top left corner in a minimum time and moves. Automatically solving the Fifteen Puzzle is very challenging because the state space for the Fifteen Puzzle contains about 16!/2≈10 13 states [2]. 15-puzzle contains 16! instances but only half of the instances are solvable [3], [4]. Optimal solutions for any solvable instances of the Fifteen Puzzle can take from 0 to 80 moves [5] [6]. The two common heuristic search algorithms, such as A* [7] and Iterative Deepening A* (IDA*) [8] have been successfully used for computing optimal solutions for the Fifteen Puzzle Instances. Those algorithms are guided by heuristic functions, which are estimates of the number of moves required to solve any given puzzle configuration.
The most common heuristic functions that have been used to reduce the search space are misplaced tile (MT), MD, LC, and Pattern Databases (PDBs) [9], [10], [11], and WD has also been used but this one is not common. Misplaced tile (MT) is the number of tiles that are not in their goal positions. MD is the sum of the distance of each tile from its goal position. LC is the sum of two moves for each pair of conflicting tiles, which are in their goal row or column positions but in the wrong order. WD was developed by [12], which counts the vertical moves and horizontal moves separately while considering the tiles' conflict with each other. PDBs are heuristics in the form of lookup tables. The two heuristics misplaced tile and Manhattan distance were used with the A* algorithm for optimally solving the 8 puzzle problems by [13]. The Manhattan distance and linear conflict heuristics were combined and used with IDA* algorithm for the Fifteen Puzzle by [14]. The walking distance heuristic was developed and used (with IDA* search) by [12] for Fifteen Puzzle. To the best of our knowledge, the walking distance heuristic has not been used in any research for Fifteen Puzzle. Pattern database heuristics were firstly introduced by [15] and then used by many researchers, and now there are various types of pattern databases [16]. The main drawback of pattern databases is that they require a large amount of memory (several gigabytes for some types of pattern databases) [16], [17]. Flener, Korf, and Hanan [18] claimed that an effective heuristic for the Fifteen Puzzle is the 7-8 additive pattern database, but this heuristic requires a lot of storage space and can be memory intensive which is about 575 megabytes.
All the heuristics used to estimate how close a state is to the goal suffer from several drawbacks. For example, some of them are not very accurate to estimate the remaining distance to a goal such as MD, MT, and WD, and the others are accurate but they require a lot of storage space such as PDBs. The main objective of this paper is to combine some heuristics to accurately estimate the cost from the current state to the goal state without generating a lot of states or requiring a large amount of storage space to store the nodes. The contribution of this paper is to hybridize three heuristics MD, LC, and WD to estimate the number of steps to the goal state. Moreover, to increase the effectiveness of the heuristic function, the MD value is divided by three. We use this heuristic in such a way as to significantly reduce the number of generated nodes to solve the puzzle states. Using those heuristic algorithms in that way cannot be guaranteed to give an optimal solution, but they usually find an optimal solution or a solution that is 1 to 6 moves far from the optimum and in some rare cases more than 6 moves away from the optimum. For the most difficult states, we run two searchesa forward search from the initial state and a backward search from the ending state (goal state), which is called a bidirectional search. This is for the sake of improving the algorithm's performance.
The remainder of this paper is structured as follows. Section 2 is devoted to presenting and discussing the implementation of our BA* algorithm. Section 3 presents and evaluates the three heuristics we use to solve the Fifteen Puzzle problem. Section 4 presents the efficient way of hybridizing the three heuristics for solving the Fifteen Puzzle. Section 5 presents and discusses the results and their comparisons. Section 5.1 compares our implementation of the BA* algorithm with the Artificial Bee Colony (ABC) algorithm in terms of efficiency and inadmissibility. Section 5.2 discusses the comparison between Bidirectional A* (BA*) search and Unidirectional A* (UA*) search. Section 5.3 describes the experiments performed with our implementation of the BA* algorithm and it also compares the obtained results of our algorithm with the results obtained by IDA* algorithm with MD and LC heuristics. Finally, Section 6 highlights the main conclusion of this study 2 Bidirectional A* Algorithm IDA* and A* are the two most popular heuristic search algorithms widely used to solve the Fifteen Puzzle problems. A* algorithm is one of the most well-regarded algorithms in artificial intelligence for finding the shortest path or the smallest number of moves from the initial state to the goal [7]. Despite being complete, this algorithm has some disadvantages that can make that algorithm inefficient, especially for complex and large puzzle problems. This is because for the difficult states billions of nodes need to be expanded and generated, and in the A* algorithm all the generated nodes are kept in memory, which can lead to running out of memory or sometimes finding a solution takes a long time. IDA* algorithm is a variant of the A* algorithm that can be implemented for solving Fifteen Puzzle [8]. Due to the reason that IDA* does not store the expanded nodes in memory, it uses less space and expands nodes faster than the A* algorithm. Even though IDA* algorithm is more efficient than the A* algorithm, we still use the A* algorithm in this paper for some reason. First of all, since we use bidirectional search, the A* algorithm is a good choice because it stores all the generated nodes in memory and this leads to frontier intersections that can be easily tested [9]. Second of all, the A* algorithm with those heuristics that we use generates a few states, and this does not cause the algorithm to run out of memory. Thirdly, since the A* algorithm retains the generated states in memory, each state is generated once. Algorithm 1 gives the pseudocode for Bidirectional A* (BA*) algorithm. Some notations are used such as OpenList, ClosedList and NeighboringState denote the states that have been visited but not expanded, the states that have been visited and expanded, and the state that is directly connected to the current state. There are separate copies of those variables for both forward and backward search, with a subscript (F or B) indicating the direction: Forward search: OpenListf, ClosedListf and NeighboringStatef, etc. Backward search: OpenListb, ClosedListb and NeighboringStateb, etc.
BA* algorithm for each one of the two searches (forward and backward search) needs two lists: a closed list which is used for storing all the puzzle states that have been visited and expanded and an open list which is used for storing the puzzle states that have been visited but not expanded. At each step, the heuristic value and the depth cost of the current state is determined. Then, the states inside the open list are sorted according to the heuristics value in increasing order. At every step, the head of the open list which has the lowest evaluation function value (which is the heuristic value plus the path cost) is removed from the open list and then checked whether it is the goal state (start state for backward search) or not. If the head state is the goal state (start state for backward search), the algorithm reconstructs the path to the goal (to the start for backward search). If the head state is not the goal (is not the start for backward search), it is checked if it is in the closed list of the opposite search direction, and if there is, it reconstructs the solution path from the two searches. When the goal (start for backward search) was not found, the head state is expanded (all the valid moves are specified) and on the closed list, it is placed. Then, all the successors of the head state which are not already on the closed list are stored in the open list. As it is shown in Algorithm 1, the forward search starts first and continues until 75,000 states are expanded but after the first step of the cycle, the forward search continues until 15,000 states are expanded. If the solution path from the start state to the goal state was not found during generating those number of states, the forward search stops, and the backward search starts. The backward search continues until 75,000 states are expanded (until 15,000 states are expanded after the first step of the cycle) if, during that period the solution path from the goal state to the start state was not found, the backward search stops, and the forward search starts again. This process will continue until the solution path is found. if Iteratorf mod 15000 is equal to 0 after the first step of the cycle or Iteratorf mod 75000 is equal to 0 then ->Expand in the backward direction, analogously

Heuristic Functions
A heuristic is an informed guess to choose the next node to visit when exploring a search space. A heuristic can lead the algorithm to a solution or fail to reach the goal. The three heuristics which are used in this paper are Manhattan distance, walking distance, and linear conflict. Figure 1: Panel (a) shows an arbitrary start state of the Fifteen Puzzle and panel (b) shows the goal state of the Fifteen Puzzle. The tiles are denoted by ti and the blank by t0. <t1, t4, t2, t3, t13, t6, t7, t8, t5, t10, t11, t0, t9, t14, t15, t12> for start state and <t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t0> for goal state shown in the Figure 1. The Manhattan distance of a puzzle is the sum of the horizontal and vertical distance of each tile (except the blank tile) from its goal position [8]. For the initial state of the Fifteen Puzzle shown in Figure 1, only the tiles t4, t2, t3, t13, t5, t9, and t12 are not in their goal positions, and they are away from their goal positions by 2, 1, 1, 2, 1, 1 and 1 respectively. Therefore, the heuristic function evaluates to 9 (2+1+1+2+1+1+1). This means that the current state needs at least 9 moves to reach the goal. Manhattan distance is admissible because it never overestimates the number of moves to the goal and each tile must at least be moved from its current position to its goal position, and only vertical and horizontal movement is allowed. Therefore, the Manhattan distance value of any state is less than or equal to the number of moves that the state needs to reach the goal. The Manhattan distance of a tile in a puzzle can be found using Equation (1) ( is the current state) [17]: LC which is used to enhance the effectiveness of the Manhattan distance, adds two additional moves to the Manhattan distance for each pair of conflicting tiles that would have to be swapped to reach the goal state. Two tiles ti and tj are in a linear conflict if both tiles are positioned in their goal row or column but in the wrong order or other words, they are reversed relative to their goal location [14]. For example, in Figure 1, tile t4 conflicts with tiles t2 and t3 because by changing the row of tile t4 we can eliminate all conflicts, and tile t13 conflicts with tiles t5 and t9 because they are in the correct column but in inverse order. In that case, t9 must do one move right to let the others pass by and then back to its column position. These four moves are not counted in Manhattan distance. Therefore, two additional moves are added to the Manhattan Distance for each pair of conflicting tiles and the heuristic evaluation function remains admissible.
Up until now the total cost function for the initial state in Figure 1 is equal to 13 (9 for Manhattan distance, 4 for linear conflict) while the optimal solution for the initial state is 29 moves. Therefore, using those two heuristics cannot make the algorithm efficient, especially for complex and large puzzle problems, and finding the solution takes a long time. This is because Manhattan distance does not capture the conflictions and interactions between the tiles, and this leads to heavily underestimating the actual optimal solution cost in almost all the problem instances of the Fifteen Puzzle figure [19], and linear conflict only adds two moves for every two tiles which are positioned in the correct row/column, but inverted. The walking distance counts the vertical moves and horizontal moves separately while considering the tile's conflict with each other [12]. According to the goal state in Figure 1, on the first row of the initial state, all the 4 tiles (t1, t4, t2, and t3) are from the 1st row of the goal state, and 0 tiles from the other rows of the goal state. The same approach is used for the other rows as is shown in Table  1. To calculate the horizontal walking distance, we can only swap the blank tile with any single tile from the above or below row and the order of the tiles on each row is irrelevant. We keep swapping until all the tiles are in their goal rows. The minimum number of moves needed to take all the tiles to their goal row positions is the horizontal Walking Distance. We can apply the same procedure to calculate the vertical Walking Distance by taking all the tiles to their goal column positions with the minimum number of moves and each tile can only be taken in a column adjacent to the column containing the blank tile, and swapping places with it. The order of the tiles on each column is irrelevant. The total walking distance is the sum of the number of horizontal and vertical moves. To more explain Table 1, Figure 2 illustrates how WD can be calculated manually step by step for the initial state in Figure 1. Two 4 by 4 tables are needed one for computing horizontal WD value and another one for computing vertical WD value. The table of the horizontal WD in Figure 2 has 4 'A' elements on the first row, this means all the tiles t1, t4, t2, t3 are from the 1st row of the goal state. It has 1 'D' element with 3 'B' elements on the second row, this is because t13 is from the 4th row of the goal, and t6, t7, t8 are from the 2nd row of the goal. It has 1 'B' element, and 2 'C' elements with a blank (t0) element on the third row, this is because t5 is from the second row of the goal, and t10, t11 are from the third row of the goal. It has 2 'C' elements with 2 'D' elements on the fourth row, this is because t9, t12 are from the third row of the goal, and t14, t15 are from the fourth row of the goal. As is shown in Figure 2, only five steps are needed to take all the tiles to their goal row position, this is the value of horizontal WD value for the initial state in Figure 1. The same procedure is used for building the table of vertical WD and calculating its vertical WD value except that when we build the table of vertical WD we must specify each tile from which column of its goal position is. As it can be seen in Figure 2, to take all the tiles to their column position six steps are needed, this is the value of vertical WD value for the initial state in Figure 1. The total walking distance is the sum of the number of horizontal and vertical moves which is 11 steps.
Since walking distance cannot be easily computed at runtime, we can precompute all these values and store them in the database because if we do not pre-compute them, this heuristic can slow the search down significantly. Instead of full calculation of walking distance during the search, Breadth-First Search (BFS) can be executed backward from the goal state to obtain all the distinct tables for all the Fifteen Puzzle configurations (all possible configurations of the tiles) which are only 24964 patterns, and store them in the database to speed up the search. The size of the database is relatively small which is about 25KB. The same database is used for calculating the number of horizontal and vertical moves. The maximum walking distance value is 70 (such as t0, t15, t14, t13, t12, t11, t10, t9, t8, t7, t6, t5, t4, t3, t2, t1), 35 moves for each horizontal and vertical moves. WD is more accurate and efficient than the Manhattan distance because the WD value is always greater than the MD value as it is illustrated in Figure 3 (The data in Figure 3 can be seen in Table 6). Figure 3 shows MD, WD, and Optimal values for Korf's 100 instances [8] after sorting the instances by optimal value. In all of them, the WD value was greater than the MD value and Table 2 shows that the total WD value for all the 100 instances is greater than the total MD value. Table 2 also shows the minimal total cost (optimal solution) and total LC values for all 100 instances.  The walking distance can also be enhanced by linear conflict because WD does not count the two moves which are determined by Linear conflict for each pair of conflicting tiles. As shown in Figure 2 during calculating the horizontal or vertical WD values when we have two tiles, which are in linear conflict, the first tile can slide to the above or below row if the row contains a blank without removing the second tile, and for the second tile is also correct. For example, Figure 4 zooms in and shows a part of Figure 2 where the tile t13 (D) that conflicts with the tile t5 (B) can slide to the third row without removing the tile t5 (B). We have built the Walking Distance lookup table for both goal states with a blank at the bottom right and top left corner since the two different goal states have been used in many types of research and we also use those two different goal states in this paper.

Hybridized Heuristic Functions
Since we have no perfect heuristic function (exact distance function) to give us the exact number of moves needed to solve all the Fifteen Puzzle instances and each heuristic has its way to calculate the distance between the current state to the goal state, it is desirable to combine multiple heuristics which can complete each other to estimate the solution cost. To more accurately estimate the cost of reaching the goal, combining several heuristics is generally the best way but it is challenging [20], [21], [22]. Multi-heuristic has been used in different ways. The most common way to use multiple heuristics is to combine different heuristics and use their maximum value. Holte et al [16] showed that taking the maximum heuristic value among several heuristics can lead to reduce node generation and result in improving the performance of the search. When two or more admissible heuristics are combined, taking their maximum, that is, by defining (hmax(s) = max(h1(s), h2(s)) is also admissible [16], [23] Another way to use multiple heuristics is cost partitioning or cost splitting, which has been used by many researchers [24], [25], [26] which is a technique to add multiple heuristic values in an admissible way with operator cost partitioning, by distributing the cost of each operator among them. This technique has a drawback in finding good cost partitioning [25]. Korf and Taylor [27] took advantage of several heuristics including Manhattan distance, linear conflict, last moves, and corner-tile to improve the accuracy of the heuristic evaluation function and result in improving the search performance of the IDA* search. In addition, they used the heuristics in a way that keeps the heuristics still admissible for example, when the same tile is involved in a corner tile and linear conflict, the extra moves are added only one time. Therefore, whenever we combine multiple heuristics and we want to find the optimal solution, we must be sure that an actual distance for any tile is not calculated more than one time. Those heuristics are not complex and it can be easily checked what tiles are involved in multiple heuristics. Manhattan distance and walking distance are the two heuristics that we use in this paper are complex and it is not easy to check which tile's actual distance to its goal position is counted by the two heuristics.
Each heuristic has its strength and weakness. Therefore, we must determine the weakness and strengths of the heuristics when we want to combine multiple heuristics to create a more accurate heuristic function. The main drawback of Manhattan distance is measuring each tile's distance to its goal position without considering interference from any other tiles [18]. For example, according to MD, the tiles t6, t7, t8, t10, t11, t14, and t15 in the initial state shown in Figure 2 need zero moves to reach their actual positions since they are already in their goal positions. This estimation is not correct because it is not possible to take the tiles t4, t2, t3 t13, t5, and t9 to their goal positions without moving some of these tiles t6, t7, t8, t10, t11, t14, and t15. On the other hand, WD considers interactions between tiles, and in some way, it calculates the distance of the tiles to their goal positions like MD. As is illustrated in Figure 5 which is a part of Figure 2, one of these tiles t7, t11, and t15 makes two moves while calculating the WD value, this proves that WD is more efficient than MD. WD is not exactly equal to MD plus the interference of tiles with each other. It seems that the WD heuristic considers interactions between tiles and the distance of each tile to its goal position but we think it cares more about the interaction of tiles than their distances to their end positions because there are many Fifteen Puzzle problem instances that have the same MD and WD value. For instance, there are 23 instances in Table 6 that have the same WD and MD values despite a lot of interactions between their tiles. Additionally, for this instance <t15, t4, t7, t11, t5, t8, t0, t3, t14, t2, t12, t13, t1, t6, t10, t9>, the WD and MD are 35 while there are a lot of interactions between the tiles. This proves that if the WD is equal to the exact MD plus the conflicts between the tiles, the WD value for the Fifteen Puzzle instance must be greater than but not equal to the MD value. Therefore, the WD is not equal to the exact MD plus the conflicts between the tiles for the Fifteen Puzzle problem instances. Despite the previous reason, WD works somehow but not exactly as MD since WD takes each tile to its goal column-row position when calculating the horizontal and vertical values for a puzzle instance as it is illustrated in Figure 2. In general, WD is more efficient and better than MD because WD is never less than MD as it is illustrated in Figure 3 and Table 6. Because of that reason we use WD and LC as the main heuristics together with MD as a helping heuristic to assist the main heuristics. Since we use MD as a helping heuristic, the MD value is divided by 3 and in that way the MD value is reduced to a number when it is added to the main heuristics' value, the result will be close to the optimal solution length.
As it was explained before WD mainly considers the interactions between the tiles and in some way it calculates the distance of the tiles to their actual positions like MD. Therefore, to compensate for the calculating tiles' distance to their goal position MD is used but not the whole MD value. The MD value is divided by a number (which is three) so that the summation of WD, LC, and MD/3 will be close to the optimal solution length. For example, if we sum the total WD value (3957), LC value (188), and MD value divided by three (3705/3) as it is shown in Table 2, the result will be 5,380, and this result is very near to the total optimal solution value 5307 for the Korf's standard 100 random Fifteen Puzzle instances. Furthermore, this total overestimation is very small and it does not have a great impact on the results of BA* as Table 6 shows that 91% of the instances are 0 to 6 moves away from their optimal solutions and reaching the goal for each instance, a small number of states are generated. Because of that reason we calculate the heuristic function in the evaluation function (Equation (2) [1]) as shown in Equation (3) named as Hybridizing Heuristic (HH). To find the shortest path, the A* algorithm uses the evaluation function as it is shown in Equation (2) which is equal to ( ) the depth cost from the start state to the current state plus the ℎ( ) the heuristic that estimates the distance from current state to the goal state. A* algorithm gurrantees optimal solution if the heuristic function is admissible.

Results and Discussions
In this section to evaluate the efficiency and performance of our implementation of the BA* algorithm, we make some comparisons. Firstly, BA* with HH is compared with the ABC algorithm in terms of admissibility. Secondly, in terms of directionality, BA* and UA* are compared to show that bidirectional search is more efficient than unidirectional search especially when there is a guarantee that the two searches of bidirectional do not pass by each other without intersecting search and they meet. Finally, the BA* search with HH is run on Korf's 100 instances, along with the comparison with IDA* search.

Inadmissible Heuristics
An algorithm can guarantee to find the shortest path or the smallest number of moves from the initial state to the goal only if the heuristic function never overestimates the actual path cost from the current state to the goal state, which we call an admissible heuristic [28]. Due to the reason that finding the optimal solution for the Fifteen Puzzle is too expensive and requires searching through a very large number of paths and generating a large number of nodes [29], many types of research have been conducted to obtain near-optimal solutions instead of exact optimal solutions [30], [31]. Thayer, Dionne, and Ruml [32] state to reduce the solving time, a near-optimal solution is a practical alternative. To reduce the number of generated nodes, we have incorporated aspects from the three heuristics to create a better one and the heuristic function in the evaluation function (Equation (2) [1]) is calculated as shown in Equation (3). As shown in Equation (3) three heuristics are combined to estimate the cost from a given state (node) to the goal state. The value of Manhattan distance is divided by three because calculating in that way, leads to fewer nodes to be generated during the search. Because of the previous reasons, the algorithm heuristic cannot guarantee to find the goal with the smallest number of moves but this brings some advantages. Firstly, a lesser number of nodes are generated and it can very quickly find the goal. Secondly, the result is very close to the optimal solution. Since a bidirectional search has been used to find the path from the initial state to the goal state, the three heuristics have been used in either direction (search).
However, our implementation of the BA* algorithm with the three heuristics does not find optimal solutions for most of the Fifteen Puzzle instances, the difference between the solution length found by BA* and the optimal solution for each puzzle instance does not increase when the puzzle instance requires more moves to optimally reach the goal. Nowadays, metaheuristic optimization algorithms are widely used for solving complex problems [33], [34], [35]. One of the algorithms that have been recently used to obtain non-optimal solutions to the Fifteen Puzzle problems was a metaheuristic algorithm Artificial Bee Colony (ABC) [36]. Here, the BA* algorithm with HH is compared with the ABC algorithm to show that the obtained results of BA* are sufficiently accurate and much nearer to the optimal results. To increase the effectiveness and performance of the heuristic function of the ABC algorithm, three heuristics PDB, MD, and LC were combined. The ABC algorithm was run on 25 randomly generated solvable instances of the Fifteen Puzzle but the algorithm did not produce an optimal solution for any of them and it provided solutions that are far from the optimum [36]. Tuncer [36] argued that the results produced by the ABC algorithm are acceptable even though the solution lengths are far from the optimal solution lengths. Furthermore, the difference between the solution costs obtained by the ABC algorithm and the optimal solutions for most of the puzzle instances increase when the puzzle instances require more moves to optimally reach the goal. For example, according to Table 3, the solution cost obtained by the ABC algorithm for the first nine puzzle instances that need fewer steps to optimally reach the goal is near to the optima while the rest of the puzzle instances are very far from the optima this is because those instances need more steps to optimally reach the goal. According to this example, the difference between the number of moves obtained by the ABC algorithm and the optimal solution will be big, especially for those states that require 80 moves to reach the goal. On the other hand, an important point about our implementation of the BA* algorithm is that the solution lengths for almost all the Fifteen Puzzle instances are 0 to 6 moves away from the optimal solution lengths even for the difficult states as is shown in Table 3, Table 4 and Table 6.
The BA* algorithm with HH was run on the same 25 initial states and the results obtained by the BA* algorithm are very near to the optimal solutions compared to the results obtained by the ABC algorithm. For example, Table 3 shows that the average number of moves in the solutions which is obtained using the ABC algorithm is 58.76 while the average number of moves in the solutions that are obtained by the BA* algorithm is 50.4. In addition, the average number of moves in the solutions found by BA* is only 1.92 away from the average cost of the optimum solution which is 48.48, while the average number of moves in the solutions found by ABC is 10.28 away from the average cost of the optimum solution. Figure 6 illustrates the obtained results of 25 states presented in Table 3 by the ABC and BA* algorithm.

Bidirectional and Unidirectional Search
In bidirectional search, two separate searches are sequentially or simultaneously run. One search is normal and starts from the initial state toward the goal state, called forward search, and the other search starts from the goal state toward the initial state, called backward search. The search process terminates once when the two searches meet at a common node in the middle and the algorithm constructs a single path that extends from the initial state to the goal state [37] [38][39] [40]. Pohl [38] was the first one who introduced and implemented a bidirectional heuristic search algorithm with the name Bidirectional Heuristic Path Algorithm (BHPA) and he showed that bidirectional search is more efficient than unidirectional search. BHPA did not work as expected since after the search frontiers meet, both directions of search pass through the opposing frontier to ensure optimality of the solution and this leads to the same node being expanded by the two searches. To resolve this issue, Kwa [41] created a Bidirectional Staged BS* heuristic search algorithm which is derived from Pohl's BHPA algorithm to avoid the re-expansion of a state that has already been expanded in the opposite search. These days, there are several types of research that prove that bidirectional search is very efficient to solve various problems [42][43] [44][45] [46].
As shown in Algorithm 1, we have implemented a bidirectional search as follows: two sequential processes are run, one branching from the start state, the other branching from the goal state. The first search "forward search" starts from the initial state and will continue until 75,000 nods are expanded. If the goal state is not reached, the second search "backward search" is initiated from the goal state towards the initial state and this search will continue until it expands 75,000 nodes. If the goal is not found, the backward search stops, and the forward search is performed again. The search process will continue to cycle until both directions meet or the solution is found. During the search, whenever a state is generated by one of the two searches, the algorithm checks if the state has already been generated by the opposite search and if there is it reconstructs a solution path from the two searches. Korf and Schultze [47] were able to compute the number of unique states at each depth of the Fifteen Puzzle. According to [47], the number of generated nodes at each depth gradually increases from depth 0 to depth 53, then the number of generated nodes at each depth starts to gradually decrease from depth 54 to 80. Based on that, the bidirectional search may not be very effective because the number of generated nodes at depth 53 decreases in both directions and it can be difficult for both searches to meet in the middle. Therefore, one of the problems for bidirectional search is that the two searches may not meet or pass by each other without intersecting, but since the A* algorithm retains all the visited nodes in the memory, this ensures that the two searches meet and frontier intersections can be easily tested [9]. Furthermore, there can be more than one optimal solution or non-optimal solution for the Fifteen Puzzle instances that can help the two searches not pass by each other without intersecting [48]. Additionally, bidirectional search is very useful when the problem has not had many goals.
Our implementation of the BA* search can reduce the number of generated states because we use a priority queue to store the estimated costs of states (nodes) and a state in the entire queue (not at a specific level) with the lowest evaluation function value (heuristic value plus the path cost) is always selected to expand. Therefore, the algorithm visits the states in order of their costs not level by level, and results in speeding up the search. Our implementation of BA* search can find optimal or near-optimal solutions even to the difficult states and with a small fraction of states expanded (and stored) compared to Unidirectional A* (UA*) search. Table 4 shows that bidirectional search is more efficient than unidirectional search concerning generated nodes. In Table 4 we run BA* and UA* searches on 28 different states that require 80 moves. The goal state with a blank tile in the top left corner is used for the first 11 instances but the goal state with a blank tile in the bottom right corner is used for the rest of 17 instances. The first nine instances were presented by [49], instances 10 and 11 were presented by [50], and the last 17 states were found by [51]. According to Table 4, BA* search is more efficient than UA* search in terms of node expansion and for ten of the states, UA* is unable to find a solution path and it runs out of memory before finding a solution. Even though the average solution cost obtained by UA* is less than the average solution cost obtained by BA*, the difference is not significant which is only 1.7. Additionally, the average number of states generated by BA* search is significantly less than those generated by UA* search, even though the number of states generated by UA* search for the 10 states has not been counted due to running out of memory. Table 5 [9] shows the comparison between the two searches UA* and BA* with HH which has been implemented in this paper. According to Table 5, the space and time complexity of the UA* algorithm is ( ) where is the branching and is the depth of solution, whereas the space and time complexity of BA* algorithm is ( 2 ⁄ ) since in BA* algorithm two searches are run, thus the solution depth is divided by two. One significant point to notice is that the time and space complexity of the A* algorithm strongly depends on the heuristics, which heuristics are used, and how they are implemented [9]. Therefore, in this paper, we took advantage of bidirectional search, the heuristics, and the way of implementing them (as shown in Equation (3)) to reduce the space complexity. Table 5 also presents the completeness and optimality of UA* and BA* with HH. It shows that both the searches are complete but not optimal, this is because of the way of using heuristics as we mentioned before that BA* with HH guarantees either optimal or near-optimal solution.

Experiments
In the study, the BA* algorithm was applied by combining the advantages of WD, LC, and MD heuristics. The algorithm was run on the 100 random initial states presented by [8], this is mainly to show the efficiency and performance of our implementation of BA*. In Korf's goal state the blank is located at the top left corner, and Korf used IDA* search algorithm with the MD heuristic. Then, those 100 random initial states were used by [14] but this time IDA* algorithm with MD and LC heuristics was run on them, and the result has been added to Table  6. Even though the implementation of the IDA* algorithm with MD and LC heuristics is quite old, we still compare our results with its results because we also use both MD and LC heuristics but in different ways and with another heuristic (WD). Furthermore, Our algorithm extremely reduces the number of generated nodes compared to the results of IDA* with the two heuristics MD and LC. Table 6 shows that the number of states examined using BA* with HH is much less than the number of states examined using IDA* with MD and LC. For example, the average cost of states examined using IDA* with MD and LC is 37,596,318 states while the average cost of states generated by BA* with HH is only 87,382 states. Furthermore, Table 6 also shows that the average solution cost that is obtained by BA* with HH is about 56.33, and this is very near the average optimal solution cost which is about 53.1 moves. In addition, the number of moves and the number of generated states in the solution of each instance using both algorithms IDA* and BA* are also shown in Table 6. Moreover, it is evident in Table 6 that the solution length of 91% of the instances from 0 to 6 moves far from their optimal solution lengths. Table 6 also demonstrates the number of state expansions and the WD, MD, and LC values for each of the puzzle instances. Figure 7 shows graphically the total number of states according to the cost difference between their optimal solutions and the solutions achieved by BA* with HH based on Table 6. Table 5 also presents that the solution of 27 states is 0 moves far from optimum (they are optimal solutions), the solution of 22 states is two moves far from optimum, the solution of 24 states is four moves far from optimum, and the solution of 18 states are six moves far from optimum. The figure also shows that only the solution of 6 states is eight moves away from optimum and the solution of three states is 10 moves away from optimum. The last column of Table 6 presents the HH value for each instance and it shows that the HH value is very near to the instance's optimal length. The average HH value, which is 54 is only 0.93 far away from the average optimal length which is 53.07.

Conclusions
In this paper, we proposed Bidirectional A* (BA*) search algorithm with three heuristics WD, LC, and MD, and the heuristics are combined in a way that guides the algorithm efficiently toward the solution and expands fewer states. It is obvious that our implementation of the BA* algorithm does not find the optimal solution for most of the Fifteen Puzzle problem instances but the solutions are very close to optimal length. Additionally, we proved using some empirical evidence that BA* heuristic search algorithm is more efficient than the UA* heuristic search algorithm in terms of state expansions.