Chapter 1 Introduction
1.6 Organization of the Dissertation
This research proposes a series of theoretical-pruning optimization algorithms and mathematical proofs for deductive games and therefore, the following studies are composed of five major parts. In Chapter 2, a complete search algorithm, depth-first
backtracking algorithm with branch-and-bound pruning, is introduced to address
Mastermind. Meanwhile, an admissible heuristic, which can be applied to various deductive games, is presented as well. Chapter 3 demonstrates a refinedbranch-and-bound algorithm with speed-up techniques for AB game in the expected
case. Three useful techniques for accelerating the speed of the search algorithm are brought up. In Chapter 4, 3×n AB games is investigated and a sophisticated method, called structural reduction, is developed to explain the worst situation in this game.Chapter 5 presents a variation of AB game, AB game with an unreliable response. An important theorem for deductive games is proven and two algorithms based on it, which are two-phase optimization algorithm with theoretical pruning and
pigeonhole-principle-based verification algorithm with theoretical pruning, are
proposed. Fortunately, an exact bound of the number of queries needed for the problem is achieved because the upper and lower bounds resulting from the two methods are equal. Chapter 6 concludes with remarkable results in our study and some future work. Moreover, two appendixes, which contain the detailed information on some proofs, are attached at the end of the dissertation.Chapter 2 Depth-First Backtracking Algorithm with Branch-and-Bound Pruning
An optimal strategy in the expected case for Mastermind has already been proposed by Koyama and Lai [47] in 1993 by using an exhaustive search but that study took too much time to search the strategy. Therefore, a more efficient algorithm, called depth-first backtracking algorithm with branch-and-bound pruning or abbreviated to DBB, is developed for solving Mastermind in this chapter. Compared to other heuristic methods, DBB can guarantee to yield the optimal tactic if the search procedure finishes. Moreover, an admissible heuristic, which can be applied to various deductive games, is presented as well. Section 2.1 gives an intuitive concept of our proposed approach. Section 2.2 introduces our depth-first backtracking algorithm with branch-and-bound pruning for Mastermind. In Section 2.3, some experimental results are discussed. Section 2.4 summarizes our concluding remarks in the chapter and a critical issue is mentioned for future research.
2.1 Introduction
Mastermind, whose dimension is 4×6, is a two-player game and both of two
players involved are the codemaker and the codebreaker. Suppose that the set of the six symbols, which may appear in secret codes, is S = {0, 1, 2, 3, 4, 5}. Thus, there are 64 = 1296 valid secret codes in Mastermind. Meanwhile, there are also 14 legal responses, which are [4, 0], [3, 0], [2, 2], [2, 1], [2, 0], [1, 3], [1, 2], [1, 1], [1, 0], [0, 4], [0, 3], [0, 2], [0, 1], and [0, 0]. The other definitions and properties are described in Chapter 1 and so, they are omitted here.
A complete algorithm with a novel pruning technique, named as a depth-first
backtracking algorithm with branch-and-bound pruning (DBB), is proposed to solve
the problem. The idea of our scheme is similar to the admissible heuristic in the A* search. The A* search is a tree search algorithm which finds a best path from a given initial state to a given goal with the lowest cost. The algorithm will terminate if a best solution is found. However, a complete search is conceptually required for our problem. Hence, DBB will search the full game tree and prune the unnecessary queries by using an admissible heuristic. The following sections will demonstrate the sophisticated algorithm and its power of searching.2.2 The Depth-first Backtracking Algorithm with Branch-and-Bound Pruning
A large number of real-world problems can be modeled as optimization problems or games. A search algorithm is therefore a general approach for them. Unfortunately, most of these problems are NP-hard or PSPACE. In other words, it has to take exponential time to search for an optimal solution. Thus, there are plenty of pruning techniques published in the literature such as A* search [62], branch-and-bound pruning [52], and so on.
Previous pruning approaches are appropriate for optimization problems since
their goal is to find a best solution in the search space. So, the search ends when it is found. A complete search is theoretically required to our problem because of the considerations of the optimal strategy in the expected case. Hence, traditional pruning approaches may not easily be applied to our problem directly.
A novel pruning technique based on the admissible heuristic in the A* search is proposed to solve the problem. In Section 2.2.1, the framework of our depth-first backtracking algorithm with branch-and-bound pruning (DBB) is introduced. Section 2.2.2 illustrates the detailed operations of our scheme.
2.2.1 The Framework of DBB
The idea of our scheme is similar to the admissible heuristic in the A* search. The
A
* search is a tree (graph) search algorithm which finds a best path from a given initial state to a given goal with the lowest cost. The algorithm will terminate if a best solution is found. However, a complete search is conceptually required for our problem. Hence, DBB will search the full game tree and prune the unnecessary queries by using an admissible heuristic. Notice that a solution described here means a strategy for the codebreaker to identify a secret code with respect to our problem.final state . . .
. . .
. . .
current state
final state s = actual cost
h'
h*: the theoretical lower bound estimated cost = h' + h*
q1 q2
Figure 4. The scenario of branch-and-bound pruning
Figure 4 shows a scenario of DBB. Suppose that h’ is the cost from the root to the current state and h* is the cost from the current state to the final state. Then, h* is called admissible if it never overestimates the cost to reach the final state. In other words, the actual cost is less than or equal to h’ + h*. It can also be viewed as a theoretical lower bound for the problem we deal with.
Our scheme traverses the game tree in depth-first fashion until a final state is reached. It then gets an actual cost s which is initially assigned to be the current-best solution. Note that the actual cost s results from the query q1 in its traversed path.
Afterwards, it soon backtracks to its parent, e.g., the current state, and picks one of the other queries, e.g., the query q2, and uses an admissible heuristic to estimate the cost h* of q2. The search continues if s is larger than h’ + h*. Otherwise, a cut happens because s is less than or equal to h’ + h*. In other words, there is no need to expand the branch of q2 and the correctness of the algorithm is still maintained. This continues in a similar manner until the full game tree is searched.
DBB (state v)
01 if (a final state is reached) then return the current-best solution s; // Final state indicates the leaf of the game tree.
02 Expand v;
03 for (each branch q of v) // Each q is a branch of v.
04 h* = ESTIMATE( q); // ESTIMATE is an admissible heuristic of
predicting the cost from q to a final state.
05 if (h' + h* < s) then // h' is the actual cost from the start state to v.
06 DBB (the states resulting from q); // Search recursively from the states resulting from q.
07 else
08 Cut the branch q; // A cut happens if h'+ h* ≥ s.
Figure 5. The depth-first backtracking algorithm with branch-and-bound pruning A rough sketch of the entire algorithm is exhibited in Figure 5. It is especially important to notice that DBB always maintains a current-best solution s during the search. Hence, DBB goes through the downward direction at first until a final state is reached. It therefore gets a current-best solution (s is updated). Then, DBB backtracks
and starts to estimate h* in each of the other queries. Unnecessary branches of the queries will never be expanded. Note that it updates s constantly when final states are encountered. So, DBB will finally obtain an optimal solution when the full game tree has been traversed completely.
2.2.2 DBB for Mastermind in the Expected Case
In this section, we will deal with Mastermind in the expected case. First, the pruning technique applied to Mastermind is introduced in Section 2.2.2.1. Second, the admissible heuristic we used is designed and explained carefully in the follow-up section. Eventually, an optimal strategy is found as a result of applying DBB to this problem.
2.2.2.1 DBB for Mastermind
According to the analyses in Table 1, the search space for Mastermind is (1296×14)5 ≈ 1021. Therefore, it takes much time to find an optimal strategy by searching the game tree completely. A pruning technique adopted by DBB is used to save a lot of time instead of making an exhaustive search. Figure 6 shows the game tree of Mastermind by applying DBB. The circles in the Figure 6 mean the states which are the sets of eligible secret codes while the diamonds are the possible queries the codebreaker can choose (1296 valid queries in each ply). In the game tree, the 14 branches produced by the codemaker’s responses should be traversed completely and the 1296 branches expanded by the codebreaker may be pruned by the admissible heuristic since we are aiming at finding an optimal strategy for the codebreaker. Let’s consider the situation exhibited in Figure 6. The traversal to the subtrees of q1 (in bold style) is just finished and q2 is now taken into account. An estimated value h* is obtained with the use of the admissible function. The subtrees below q2 do not have to be expanded if the result of expanding q1 is better than h*. This is the key idea of DBB
and the search can thus be completed in a more reasonable time. Note that the correctness of DBB is preserved because of the admissible heuristic.
Figure 6. The game tree of Mastermind by applying DBB
2.2.2.2 The Admissible Heuristic for Deductive Games
Now the most critical issue is how to design an admissible heuristic function to estimate the theoretical lower bound h*. Note that minimizing the number of queries in the expected case is the same as minimizing the external path length of the game tree. So, the concept of volumes introduced by Huang et al. [38] is involved to get the theoretical maximum bounds for the 14 classes (responses). In order to make sense, the term, “response”, is replaced by “class” here. We know that different queries in a certain ply result in distinct distributions of the eligible codes in 14 classes. The distribution discussed here is the sizes of 14 classes resulting from a certain query.
Thus, the volume of a class [x, y] is defined as the maximum value of the numbers of the eligible codes when the codebreaker makes all the valid queries in one ply and the codemaker responses with [x, y]. In the beginning, at the root of Figure 6, there is a
total of 1296 secret codes. While the first query is considered, there are 5 nonequivalent queries in 1296 possible codes, i.e., “0000”, “0001”, “0011”, “0012”, and “0123” for the codebreaker [47]. If the codebreaker queries “0000” and the codemaker gives the response [1, 0], then we can derive that there are 500 possible secret codes. Similarly, if the codebreaker queries “0001”, “0011”, “0012”, or “0123”, and the codemaker gives the response [1, 0], then we can derive that there are 317, 256, 182, and 108 possible secret codes, respectively. So, the volume of the class [1, 0]
is set to be 500, the maximum value of these numbers: 500, 317, 256, 182, and 108.
With the use of Get_volume function (see Huang et al. [38]) based on the above idea, the volumes of the 14 classes (responses) are obtained as in Table 4.
Table 4. The volumes of 14 classes calculated by Get_volume function
class [4, 0] [2, 2] [1, 3] [0, 4] [3, 0] [2, 1] [1, 2] [0, 3] [2, 0] [1, 1] [0, 1] [0, 2] [1, 0] [0, 0]
volume 1 6 8 9 20 48 132 136 150 252 308 312 500 625
The same principle of the extended pigeonhole principle presented by Chen et al.
[18] is therefore employed to estimate the lower bounds of the queries needed.
However, there are major differences between the problem in the previous study (Chen et al. [18]) and this problem we consider now. Only the worst case among the 14 classes is considered for the codemaker in that paper. The so-called “worst case”
denotes the response (class) which will result in the maximum number of queries required by the codebreaker. But each class should be taken into account for our problem.
The heuristic function here has to calculate the “theoretical optimal” number of queries in the expected case for a certain query (or called the lower bound of a certain query) for the codebreaker. Suppose that the lower bound of a query q is assessed by the codebreaker. The query q results in 14 classes. It will assume that there exists an
optimal strategy such that all of the eligible codes in each class may be divided evenly in the following queries. The rated value calculated by this heuristic for a state (one of the 14 classes) is the external path length (EPL) of the subtree that is yielded by the theoretical optimal strategy we imagine. So, the actual expected number of queries is thus larger than or equal to the estimated value. Trivially, the heuristic is admissible because a theoretical optimal strategy is assumed to rate the EPL of the subtree of each class formed by q. Moreover, it can be applied to any deductive games by adjusting the number of legal classes (the number of legal responses the codemaker can give) and its volume of each legal class since any other specific knowledge do not have to be considered. In other words, the lower bound of a query q by utilizing this heuristic is equal to the summation of each EPL with respect to 14 classes plus the size of the state, which is the original state before q is made.
Figure 7. An example of the calculation of the admissible heuristic for Mastermind A simple example to illustrate the calculation of the EPL regarding some class (state) yielded by q is shown in Figure 7 with the use of the proposed admissible heuristic. Given a state with a size of 17, as shown in Figure 5, we imagine that the theoretical optimal strategy will divide the 17 eligible codes into 14 classes evenly without exceeding the corresponding volumes. The number in the lower half of the
circle is the volume of each class and the number in the upper half is the number of eligible codes in it. Since there is 1 leaf at level 1, 13 leaves at level 2, and 3 leaves at level 3, it is obvious that the external path length of the tree is 1×1 + 2×13 + 3×3 = 36 in the ideal situation. Thus, the external path length of the example must be smaller than or equal to the actual expected number of queries. It is therefore easy to see that the heuristic is admissible because it never overestimates the expected number of queries.
2.3 Experimental Results
In order to analyze the performance of the proposed DBB, we demonstrate the results of the original version of Mastermind (4×6 Mastermind) and another version of Mastermind, which is 3×5 Mastermind. 3×5 Mastermind has smaller search space in the case of 3 digits with 5 possible symbols. That is to say that it has 53 = 125 possible secret codes totally. Note that the equivalent properties proposed by Neuwirth [53] are able to reduce the search space. For example, “0000” is equivalent to “1111” at the first query because the numbers, 1 and 2, are both not used before.
With the considerations of the properties, there are five nonequivalent queries at the first query, which are “0000”, “0001”, “0011”, “0012”, and “0123”. The branching factor in the first ply changes from 14×1296 to 14×5 eventually. This technique has also been implemented in our programs in order to speed up the search.
Besides the comparison between 3×5 Mastermind and 4×6 Mastermind, we also investigate the effect of the traversing order during the search. In other words, we have to decide which query is promising when several queries are encountered after the current state is visited. To deal with this issue, we estimate the lower bounds of the child states by making use of the admissible heuristic before they are expanded.
We sort their lower bounds and traverse these queries order-by-order in accordance
with their values. The smaller the value is, the earlier the traversal is. All experiments were run on a dedicated PC with an AMD Opteron 252 processor. The experimental results are exhibited in Table 5.
Table 5. The experimental results of two versions of Mastermind 3×5
Mastermind
4×6 Mastermind DFS > 10 hr. > 10 days
DBB 38.68 sec. 43.76 hr.
DBB (promising query) 11.21 sec. 9.5 hr.
External path length 451 5625
DFS is the abbreviation of depth-first search while the term, “promising query”, means that DBB expands the queries in nondecreasing order according to the values of lower bounds. We can see that DBB is able to obtain the optimal strategies for the two versions and their corresponding external path length is 451 and 5625, respectively. This means that the expected number of queries is about 4.34 (≈5625/1296) for Mastermind if we apply the optimal strategy in the expected case.
The results also show that DBB with the considerations of promising queries has the best performance. Without the judgement of promising queries, DBB will traverse a lot of useless queries. That is to say that most queries will be cut if DBB expands queries in the correct order.
From the experimental results, DFS has very poor performance doubtlessly since it is certainly an exhaustive search. Hence, DFS can not search the full game tree in a reasonable time and the total number of the states it has to expand is still unknown.
On the other hand, DBB is significantly superior to and is over 25 times faster than DFS. Totally, there are 137834651 states expanded by DBB. The results also reveal that the larger the search space is, the more important the pruning technique is.
2.4 Chapter Conclusion
Previously, an exhaustive search was applied to find the optimal strategy for Mastermind. But it may not be adopted in other harder problems or games because of its huge search time. In this chapter, a more efficient depth-first backtracking
algorithm with branch-and-bound pruning (DBB) for Mastermind in the expected
case is introduced, and an alternative optimal strategy is obtained eventually.Moreover, an admissible heuristic, which can be applied to various deductive games, is presented as well. From the experimental results, the effect of expanding promising queries during the search is significant to the performance of DBB. Meanwhile, DBB is significantly superior to and is over 25 times faster than the traditional search algorithm. How to design a more precise admissible heuristic is yet another critical issue. Furthermore, it may be interesting to compare our method with other search algorithms or other heuristics mentioned in the previous studies with the consideration of the qualities of solutions and the search time.
Chapter 3 Refined Branch-and-Bound
Algorithm with Speed-up Techniques
Another famous deductive game is AB game, which is popular in Asia and England. However, to date, there have been no optimal expected-case strategies for AB game in formal literature since its appearance. Since the complexity of these deductive games grows at an exponential rate with higher dimensions, DBB can not be directly applied to efficiently solve AB game in the expected case.
In this chapter, a refined branch-and-bound algorithm with speed-up techniques, which is abbreviated to RBB, is demonstrated for AB game in the expected case. This algorithm is based on DBB and three useful techniques such as the incremental update of the lower bounds, the hashing technique, and the reduction of equivalent queries are invented to integrate with it. Therefore, RBB will lead to the hope that the optimal tactic of AB game in the expected case is attained. Section 3.1 reviews our handled problem and compares the search space between Mastermind and AB game. Section 3.2 introduces a refined branch-and-bound algorithm while new techniques and significant improvements are demonstrated here as well. In Section 3.3, some experimental results and discussions are given. Section 3.4 summarizes the
remarkable results in this chapter.
3.1 Introduction
AB game, which is also called “Bulls and Cows” in England, is another popular deductive game around the world for decades as well. Its dimension is 4×10 and there
AB game, which is also called “Bulls and Cows” in England, is another popular deductive game around the world for decades as well. Its dimension is 4×10 and there