Chapter 3 Refined Branch-and-Bound Algorithm with Speed-up Techniques
3.3 Experimental Results and Discussions
3.3.2 Performances and Results of RBB for Solving Mastermind and AB Game
In order to examine the performance, a deductive game with smaller dimensions,
Mastermind, is first explored with the proposed approach composed of all significant refinements except Technique 3. Technique 3 can not be applied in Mastermind because repeated symbols are allowed in the queries of the game. The program relied upon RBB therefore finished the work with 43 minutes in the experiment and gained the optimal EPL that is 5625. This means that the expected number of queries of the optimal strategy in the expected case for Mastermind is 5625/64 ≈ 4.34. On the other hand, it has to take 451 minutes to complete the same work with the use of DBB.
Hence, RBB outperforms DBB by 10 times faster only with the first two techniques.
Note that DBB explores 137834651 states during the searching process while RBB only expands 31720272 states.
With the success, RBB integrating all the three techniques to find the optimal tactic of AB game in the average case was thereby undertaken. An invaluable result was eventually gained in about 18 days (From Nov. 6, 2008 to Nov. 23, 2008). The optimal strategy for AB game was therefore obtained and its corresponding EPL is 26274. Moreover, a partial strategy is also presented in Appendix B. Now we have the following theorem.
Theorem 1. The expected number of queries of the optimal strategy in the expected
case for AB game is 26274/5040 ≈ 5.213.3.4 Chapter Conclusion
In this chapter, we focus on finding the optimal strategy in the expected case for AB game. An elegant approach, which is named as refined branch-and-bound
algorithm with speed-up techniques (RBB), essentially based on the incremental
update of lower bounds, the hashing technique, and the reduction of equivalent queries is designed to explore its huge search space. In the development of pruning techniques, we also realize that the ratio of pruning is significant if the pruning isbased on theoretical analyses. In order to compare RBB with DBB, Mastermind is first addressed by applying these two methods individually. A dramatic improvement is exhibited in the outcomes and RBB outperforms DBB over 10 times faster.
Fortunately, an optimal strategy for AB game in the expected case is eventually obtained by utilizing RBB. The corresponding external path length is 26274. In other words, the expected number of queries required by the codebreaker is 26274/5040 ≈ 5.213. Note that Appendix B attached at the end of this dissertation contains the partial optimal strategy for AB game, which is discovered by RBB.
Chapter 4
Structural-reduction Approach
In this chapter, a sophisticated method, called structural-reduction approach (SR), which aims at explaining the worst situation in 3×n AB games is developed.
Section 4.1 introduces our addressed problem and additional definitions that are used in this chapter. Section 4.2 analyzes the optimal strategies for the codebreaker and the devil’s strategy for the codemaker. In Section 4.3, a practical example is offered to describe the pessimistic situation of this game. Section 4.4 concludes with our analyses and a worthwhile formula for calculating the optimal numbers of queries required for arbitrary values of n is derived and proven finally.
4.1 Introduction
3×n AB games means that there are 3 digits in a single secret code and each digit has n possibilities (symbols). Suppose that the set of symbols appearing in 3×n AB games is S = {0, 1, 2, …, n − 1}. From the analyses of Chapter 1, the number of all legal responses is 9 and these responses are [3, 0], [2, 0], [1, 2], [1, 1], [1, 0], [0, 3], [0, 2], [0, 1], and [0, 0] respectively. Meanwhile, the number of all possible secret codes equals to n(n − 1)(n − 2) as well. For example, assume that the codemaker chooses c = 215 as a secrete code and the codebreaker makes a query g = 012. Then, the codemaker will offer a response [1, 1].
Before 3×n AB games are discussed formally, some additional definitions besides those offered in Chapter 1 have to be explained first in order to describe the analyses precisely. Thus, they are defined as follows.
Definition 12. Let C
1 and C2 denote two states in the game tree. We say that C1 isharder than C
2 if identifying a secret code in C1 requires more queries than that in C2. In other words, the difficulty of a state means how many queries the codebreaker requires to identify a secret code.Definition 13. A strategy of responses taken by the codemaker is called a devil’s
strategy or an adversary response if this strategy maximizes the
number of queries required by the codebreaker.Definition 14. Suppose that there are two states, which are C
1 and C2 respectively. If there exists a one-to-one function r such that each secret code in C1maps another one in C2 and preserves the structure of C1, then we say that C2 dominates C1. Furthermore, r is called a structural reduction. In symbols, we write C1 ≤ C2.
Now, 3×5 AB game is taken into account as an illustrative example. Suppose that the set of five symbols in this simple game is S = {0, 1, 2, 3, 4}. If the codebreaker makes a query, 012, and the codemaker responses [2, 0] in the first ply, the eligible codes are therefore 013, 014, 032, 042, 312, and 412 after the first ply. The set C[2,0] = {013, 014, 032, 042, 312, 412} forms a state. From the result of the later experiment, which conducts an exhaustive search to 3×5 AB game, the number of queries required is maximum if the codemaker implements a devil’s strategy to provide the response, [0, 2], at the first response.
On the other hand, C[2,0] and the state, C[1,0] = {043, 034, 432, 342, 314, 413}, which is produced when the codemaker responses [1, 0] at the first response, are then
considered. Notice that the elements in C[2,0] are of the forms, 01b, 0b2, or b12, where . Thus, we define a structural reduction of r as
{ }
3,4=
∈ B
b
⎪ { }
⎩
⎪ ⎨
⎧
−
∈
∈ z
b b
b B z B b zb
b
zb b
r
1 12
. and
where ,
2 2
0
0 01 :
a a a
Figure 1 exhibits the mapping of each code in C[2,0] in detail. Note that the mapped codes in C[1,0] preserve the structures of those in C[2,0]. This implies that finding a secret code in C[1,0] is as hard as or harder than that in C[2,0]. Intuitively, this is also obvious since there is one more identified symbols in C[2,0] than in C[1,0]. Hence, we say that C[1,0] dominates C[2,0]. Furthermore, the structural reduction has the property of the transitive relation obviously. That is to say that given three states, C1, C2, and
C
3, C1 ≤ C3 if C1 ≤ C2 and C2 ≤ C3.013 014 032 042 312 412
043 034 432 342 314 413
r
C
[2, 0]C
[1, 0]Figure 13. Mapping from codes in C[2,0] to those in C[1,0] for 3×5 AB game
4.2 Optimal Analyses for the Codebreaker and the Codemaker
In this section, we divide the analyses into two parts. The first part discuss a special kind of states C* that will be considered to determine the best query for the codebreaker when he encounters this kind of states. Then, the discussion in the next
part will reveal that the special states that are discussed here just match the attribution of states resulting from the devil’s strategy for the codemaker. Consequently, our conclusions are attained finally.
4.2.1 Analyses of the Optimal Queries for the Codebreaker
Before the formal discussion, a critical concept should be clarified first.
Intuitively, the more secret codes a state has, the harder the codebreaker identifies a secrete code in it. However, the rule is not absolutely correct especially when the size of one state is very close to that of the other. Hence, the structural reduction is adopted to determine the difficulties of two states instead of simply comparing their sizes in the following discussion.
Suppose that S = {0, 1, 2, ..., n − 1} represents the set of symbols appearing in 3×n AB games. The set, B = {b0, b1, ..., bh-1}, is a subset of S, where bi ∈ S and |B| = h, 3 ≤ h ≤ n − 3. Moreover, another set, A, is defined as A = S − B = {a0, a1, ..., an-h-1}, whose cardinality is (n − h).
Assume that there is a special state, called C*, which consists of the secret codes that are all possible permutations of h symbols in B. In other words, the special state has h(h − 1) (h − 2) secret codes in it. This state may be regarded as a subproblem of a 3×n AB game, i.e. a 3×h AB game. Notice that the symbols in A do not appear in the codes of the special state because of the definition of C*. We can intuitively treat the symbols in A as those eliminated from previous responses made by the codemaker.
Now, imagine a scenario where C* is encountered for the codebreaker during the process of playing a 3×n AB game. Since any symbols in S may be used in a query made by the codebreaker for a 3×n AB game, all possible queries for the codebreaker can be classified into four types according to the numbers of symbols that belong to A and B. Thus, the four types of queries for the codebreaker are listed and discussed as
follows. Here we suppose that ai, aj, ak ∈ A and bi, bj, bk ∈ B.
1. ai
a
ja
kAll symbols of this type of queries belong to A. If the codebreaker makes this kind of queries, all eligible codes are then classified into the substate, C[0,0], trivially. So, the queries of Type 1 are redundant and non-optimal results will be obtained if the codebreaker chooses this kind of queries.
2. bk
a
ia
j, aib
ka
j, and aia
jb
kThe queries of Type 2 contain two symbols in A and one symbol in B. This type of queries can be further divided into three kinds of queries such as bk
a
ia
j, aib
ka
j, anda
ia
jb
k in accordance with their positions of symbols. Without loss of generality, g =b
ka
ia
j is taken to conduct the following analyses. The discussions of the other two can be undertaken in a similar way. Three nonempty substates, which are C[1,0],C
[0,1], and C[0,0], are produced as the codebreaker makes the query g. Note that their cardinality are (h − 1)(h − 2), 2(h − 1)(h − 2), and (h − 1)(h − 2)(h − 3) respectively.Now, we can show that C[0,1] ≤ C[0,0] and C[1,0] ≤ C[0,0] if h ≥ 5.
Lemma 1. If the codebreaker encounters the state, C
*, and then makes the query, g= bk
a
ia
j, aib
ka
j, or aia
jb
k, where ai, aj ∈ A and bk ∈ B, then C[0,0]dominates C[0,1] and C[1,0] if h ≥ 5.
Proof. In order to prove that C
[0,1] ≤ C[0,0], a structural reduction, r1, is defined as{ } { }
⎩⎨
⎧
′−
∈
−
′=
∈ and , , .
, where : ,
2 1 2
1 1
q p k
q p q
p k q p
q p q k p
b b B z z B
B B b b z
b b b b b
b z b b b r b
a a
From r1, it reveals that the structures of the secret codes, which are bp?bq and bp
b
q?, are preserved after mapping. Note that bpz
1b
q and bpb
qz
2 should be distinct to reserve the property of one-to-one mapping. We can achieve this by assigning the symbols of z1 and z2 carefully while mapping is conducted. On the other hand, there should be two symbols left for the assignments of z1 and z2 once bp and bq havebeen fixed during the mapping. The proof is therefore correct if h ≥ 5. The proof of
C
[0,1] ≤ C[0,0] is finished now. Afterwards, another structural reduction, r2, is defined as{ }
and{
,}
., where ,
: 1 1
2
b
kb
pb
qz b
pb
qb
pb
qB B b
kz B b
pb
qr
a ∈ ′= − ∈ ′−There should be one symbol left for the assignment of z1 once bp and bq have been assigned. Hence, the proof is right if h ≥ 4. In other words, C[1,0] ≤ C[0,0]. From the results of r1 and r2, we know that C[0,0] dominates C[0,1] and C[1,0] when h ≥ 5. This completes the proof of Lemma 1.
3. ai
b
jb
k, bja
ib
k, and bjb
ka
iThe queries of this type are composed of a symbol in A and two symbols in B.
These queries can also be further classified into three kinds of queries, i.e., ai
b
jb
k,b
ja
ib
k, and bjb
ka
i. Without loss of generality, g = aib
jb
k is choosen to undertake the following discussions. Besides, the analyses of bja
ib
k and bjb
ka
i can be derived in a similar way and so, they are omitted here. There are six nonempty substates after the codebreaker makes the query g. They are C[2,0], C[1,1], C[0,2], C[1,0], C[0,1], andC
[0,0] respectively. Note that their corresponding cardinality are (h − 2), 2(h − 2), (h− 2), 2(h − 2)(h − 3), 4(h − 2)(h − 3), and (h − 2)(h − 3)(h − 4). Now, we show that
C
[0,0] dominates the other five substates if h ≥ 8.Lemma 2. If the codebreaker encounters C
*, and then makes the query, g = aib
jb
k,b
ja
ib
k, or bjb
ka
i, where ai ∈ A and bj, bk ∈ B, then C[0,0] dominates C[0,1],C
[1,0], C[0,2], C[1,1], and C[2,0] when h ≥ 8.Proof. Five structural reductions, called r
3, r4, r5, r6, and r7, are defined as follows to certify that C[0,1] ≤ C[0,0], C[1,0] ≤ C[0,0], C[0,2] ≤ C[0,1], C[1,1] ≤ C[1,0], and C[2,0] ≤C
[1,0] respectively.{ } r
6 have to be distinct as well. We can attain this with assigning these symbols of z1,z
2, z3, and z4 carefully when mapping is undertaken. In order to meet requirements of the assignments of zi in r3, r4, r5, r6, and r7, the following conditions should be maintained respectively: h ≥ 8, h ≥ 6, h ≥ 6, h ≥ 5, and h ≥ 4. Consequently, it is true that C[0,0] dominates C[0,1], C[1,0], C[0,2], C[1,1], and C[2,0] while h ≥ 8. Hence, the proof of Lemma 2 is completed.4. bi
b
jb
kAll symbols of this kind of queries belong to B entirely. There are totally nine nonempty substates, which are C[3,0], C[1,2], C[0,3], C[2,0], C[1,1], C[0,2], C[1,0], C[0,1], and
C
[0,0] respectively, as the codebreaker makes the query, g = bib
jb
k. Notice that their cardinality are 1, 3, 2, 3(h − 3), 6(h − 3), 9(h − 3), 3(h − 3)(h − 4), 6(h − 3)(h − 4),and (h − 3)(h − 4)(h − 5) respectively. In the following statements, we would in B and thus, the three symbols can be permuted appropriately to map the three substates. On the other hand, five definitions of structural reductions, which are named as r8, r9, r10, r11, and r12, are provided as follows to confirm that C[0,1] ≤ C[0,0],
{ } {
should be distinct from each other to reserve the one-to-one mapping property. This can be attained by assigning these symbols of z1, z2, z3, z4, z5, and z6 carefully. On the other hand, to satisfy each assignment of zi in r8, r9, r10, r11, and r12, the following constraints have to be kept respectively: h ≥ 11, h ≥ 8, h ≥ 6, h ≥ 6, and h≥ 5. So, it is therefore correct that C[0,0] dominates C[0,1], C[1,0], C[0,2], C[1,1], C[2,0],
C
[0,3], C[1,2], and C[3,0] when h ≥ 11. Hence, the proof of Lemma 3 is completed.After four kinds of queries for the codebreaker are discussed, only three kinds of queries among them are useful since the first one causes non-optimal results trivially.
In order to simplify the notations, let C(2), C(3), and C(4) denote the hardest states caused by queries of Type 2, Type 3, and Type 4 respectively. Hence, the difficulties of these three states have to be determined to choose the best query for the codebreaker. The following lemma therefore describes the phenomena.
Lemma 4. When the codebreaker encounters C
*, the hardest states caused by queries of Type 2, Type 3, and Type 4, i.e. C(2), C(3), and C(4), are produced. Thus, we have C(4) ≤ C(3) ≤ C(2).Proof. From the meanings of C
(2), C(3), and C(4), it reveals that C(2) is composed of secret codes that are permutations of (h − 1) symbols, and C(3) consists of what arepermutations of (h − 2) symbols while the codes in C(4) are permutations of (h − 3) symbols. Let S(2), S(3), and S(4) denote the sets of symbols appearing in C(2), C(3), and
C
(4) respectively. Then, let the symbols in S(2), S(3), and S(4) be sorted separately according to the lexicographical order. A mapping is generated naturally if we map each symbol in S(4) to that in S(3) one by one in sorted order. So does the mapping between S(3) and S(2). Obviously, we have C(4) ≤ C(3) ≤ C(2). This proof is completed entirely.Concluding with Lemma 1, Lemma 2, Lemma 3, and Lemma 4, we have the following lemma.
Lemma 5. For a special state, C
*, which also represents a 3×h AB game (11 ≤ h ≤ n), the optimal query for the codebreaker now is bib
jb
k, where bi, bj, bk ∈ B.Proof. From Lemma 4, C
(4) is the easiest state to identify a secret code compared toC
(2) and C(3). The goal of the codebreaker is to minimize the number of queries required and so, the codebreaker has to choose the query which results in C(4) in the worst situation. The optimal query for the codebreaker is therefore bib
jb
k.4.2.2 The Devil’s Strategy for the Codemaker
Since the mission of the codebreaker aims to minimize the number of queries to acquire a secret code, the codemaker tries to maximize the number of queries for the codebreaker if he decides to implement a devil’s strategy. Hence, the worst case for the codebreaker means that his opponent conducts a devil’s strategy (or called a worst response for the codebreaker) in each ply during the gaming process in order to maximize the number of queries. In the follow-up, a lemma is exhibited to demonstrate what is the worst response for the codebreaker if he encounters a 3×h AB game, where h ≤ n.
Lemma 6. For a 3×h AB game, where 11 ≤ h ≤ n, the codebreaker will require a
maximum number of queries to get the code while the codemaker answers [0, 0] after the codebreaker’s query.
Proof. From Lemma 5, it is obvious that the codebreaker must choose b
ib
jb
k as a query for a 3×h AB game. After the codebreaker makes the optimal query, nine substates will be formed. These substates are C[0,0], C[0,1], C[1,0], C[0,2], C[1,1], C[2,0],C
[0,3], C[1,2], and C[3,0] respectively. C[0,0] dominates C[0,1], C[1,0], C[0,2], C[1,1], C[2,0],C
[0,3], C[1,2], and C[3,0] in accordance with the result of Lemma 3. In other words, C[0,0]is the hardest substate among the nine ones. Conclusively, the codemaker must response [0, 0] as his worst response and this will result in the worst case for the codebreaker because of the maximum number of queries. The proof is therefore finished.
4.3 An Illustrative Example of the Pessimistic Situation
In order to clarify the key idea of the pessimistic situation (worst case) of 3×n AB games we have discussed above, a 3×20 AB game, which is a 3×n AB game while n = 20, is taken as an illustrative example. The scenario is shown in Figure 14. Suppose that the set of symbols is S = {c0, c1, …, c19}. In the first ply, the codebreaker makes the first query, c0
c
1c
2, and the codemaker offers [0, 0] as the first response which is the worst-case response. Thus, the 3×20 AB game reduces to a 3×h AB game, whereh = 17. The similar operations proceed at the second and third queries. After the third
query and third response, the original 3×20 AB game reduces to a 3×11 AB game.The minimum number of queries can not be obtained easily with the use of analyses when h ≤ 11 because of the irregular behavior. Hence, a branch-and-bound search algorithm, which has been proposed in Chapter 2, is applied to find an optimal strategy for smaller h.
Figure 14. The scenario of the pessimistic situation of a 3×20 AB game
4.4 Chapter Conclusion
From the above discussions, the optimal query for the codebreaker and the adversary response for the codemaker, which refers to the worst case for the codebreaker as well, are eventually obtained with the consideration of the special state
C
*. In the follow-up, all results mentioned above will be concluded to derive a theorem.Theorem 2. For a 3×n AB game, the minimum number of queries for the
codebreaker in the worst case is⎣ ⎦ ( )
⎣ ⎦
⎩ ⎨
⎧
≥ +
+
≤
≤ +
. 8 if , 3 3 1
7 3
if , 3
3
n n
n n
Proof. At the beginning of a 3×n AB game, the n symbols are not used and then all
secret codes are all equivalent. As a result, a secret code is chosen randomly as the first query for the codebreaker. Nine substates are therefore produced and [0, 0] is taken as an adversary response according to Lemma 6. Afterwards, C[0,0], which results from the first response, matches the attribution of the special state C* described in Lemma 5. Thus, Lemma 5 can be applied to this state. We find that the situations
mentioned in Lemma 5 and Lemma 6 will appear alternately in the following gaming process. So we have the following recurrence.
( ) ( n =T n
−3)
+1, whenn
>11.
T
Because of the irregular behavior of a 3×n AB game with a smaller value of n, its minimum number of queries can be obtained with the use of a branch-and-bound search algorithm, which originates from Chapter 2, when n ≤ 11. After the use of computer programs written with this approach, the minimum numbers of queries required for the codebreaker in the worst case are obtained in several hours and they are 4, 4, 4, 5, 5, 6, 6, 6, and 7 respectively when n = 3, 4, 5, 6, 7, 8, 9, 10, and 11. For example, an optimal strategy for 3×7 AB game is considered with S = {0, 1, 2, 3, 4, 5, 6}. If the codemaker takes 165 as a secret code, a gaming process in the worst case will be as follows: 012, [0, 1], 023, [0, 0], 041, [0, 1], 156, [1, 2], 165, [3, 0]. In other words, the codebreaker requires 5 queries to identify 165 while playing the worst-case optimal strategy.
We derive the above recurrence and conclude with the results of smaller values of
n. Hence, the closed form of the formula is exhibited as follows.
⎣ ⎦ ( )
⎣ ⎦
⎩ ⎨
⎧
≥ +
+
≤
≤ +
. 8 if , 3 3 1
, 7 3
if , 3
3
n n
n n
This completes the proof.
Partial results of 3×n AB games, 3 ≤ n ≤ 16, are summarized in Table 12. As 3×n AB games have been solved successfully, a natural generalization is to explore the techniques for m×n AB games, where m ≥ 4. This problem remains open.
Table 12. The minimum number of queries for 3×n AB games in the worst case
n 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# of queries 4 4 4 5 5 6 6 6 7 7 7 8 8 8
Chapter 5 Optimization Algorithm and
Verification Algorithm
This chapter introduces two algorithms, called the two-phase optimization
algorithm (TPOA) and pigeonhole-principle-based verification algorithm (PPV) to
investigate the game, AB game with an unreliable response. TPOA was proposed by us in [17] and was proved to be an effective approximate algorithm for deductive games. PPV is modified slightly from the pigeonhole-principle-based fast backtracking algorithm in [37], which was also demonstrated by us. Section 5.1 gives a comprehensive introduction for our problems while some notations are redefined here to match the properties of the handled problem. Section 5.2 provides an introduction to TPOA and its performance. In Section 5.2.3, PPV is illustrated and the verified results are also shown. Section 5.4 contains the summary of our remarks.5.1 Introduction
In this chapter, a variant of AB game, which is called AB game with an unreliable response, is presented. The game is the same as 4×10 AB game in addition to the concept of fault tolerance added to the variant. In other words, there is an
additional rule in the game ⎯ the codemaker is allowed to give at most a wrong response. For example, it is a wrong response if the codemaker answers [1, 0] instead of [1, 2] if the codemaker chooses “2134” as a secret code and the codebreaker makes a query “0123”. Furthermore, the termination criterion of the game is modified in order to fit in with the area of fault tolerance. That is, the game is over if there is only one eligible code now. In short, it is not necessary for the codebreaker to figure out the secret code but to acquire it in his mind.
AB game with an unreliable response has ever been studies by us [37]. That results show that the upper bound of the required number of queries in this game is 9 while the lower bound of it is 8. Unfortunately, the two bounds are not the same and then, two more effective algorithms will be exhibited in this chapter to decide the exact bound of it.
〈{0, 1, 2}, {}〉
g1,2 = 1
〈{0}, {1, 2}〉
g2,1 = 0
〈{1}, {0, 2}〉
g2,2 = 1
〈{2}, {0, 1}〉
g2,3 = 2
〈{}, {0}〉〈{0}, {}〉〈{}, {0, 1, 2}〉
g3,2 = 1
〈{}, {0, 1}〉
g3,1 = 0
〈{}, {1, 2}〉
g3,2 = 1
〈{1}, {}〉 〈{}, {0, 1, 2}〉
g3,2 = 1
〈{ 2}, {}〉〈{}, {2}〉
〈{}, {0}〉〈{}, {1}〉〈{}, {2}〉 〈{}, {0}〉〈{}, {1}〉 〈{}, {1}〉 〈{}, {2}〉〈{}, {0}〉〈{}, {1}〉〈{}, {2}〉
< = >
< = > < = > < = >
< = > = > = > < = >
Figure 15. A game tree for the 1×3 game with an unreliable response
In order to clarify the problem and our proposed methods precisely, here we redefine some notations, which may have been defined in Chapter 1, to match the properties of AB game with an unreliable response. Consequently, a simple number
guessing game, denoted 1×n games with an unreliable response, is taken as an illustrative example to explain these new notations. In the 1×n games with an unreliable response, the codemaker chooses a secret code c, c = {0, 1, 2, …, n − 1}.
After each query g made by the codebreaker, the codemaker gives him a response r, r
= {<, =, >}, i.e., they stand for g < s, g = s, and g > s. The codemaker is allowed to give at most a wrong response in this game. The goal of the game is to obtain the
= {<, =, >}, i.e., they stand for g < s, g = s, and g > s. The codemaker is allowed to give at most a wrong response in this game. The goal of the game is to obtain the