Brinkmate Search. University of Library Information Science. Abstract

Brinkmate Search Hiroyuki IIDA Department of Computer Science Faculty of Information Shizuoka University Fumiya ABE Department of Computer Science Un...
Author: Roderick Fowler
0 downloads 1 Views 187KB Size
Brinkmate Search Hiroyuki IIDA Department of Computer Science Faculty of Information Shizuoka University

Fumiya ABE Department of Computer Science University of Library Information Science Abstract

This paper explores brinkmate search for chess-like games. Since not much is known about brinkmate search, we rst explain this idea. Then we propose an algorithm of brinkmate search based on the concept of threat sequence. The brinkmate-search algorithm described in this paper has been implemented into our brinkmate solver and the results using some test set are presented.

Content area: Game Playing, Brinkmate Search, Mate Search. 1

Introduction

Brinkmate search is really important in the endgame of any chess-like game, since it often is the easiest achievable target which may lead to a win. As there is a Shogi proverb; \brinkmating with short steps is much better than mating with long steps", the skill of brinkmating is signi cantly important especially in Shogi, since most games of Shogi do not result in a draw but in a mate. In this paper, we rst de ne some terms related to the general concept of brinkmate and we outline some previous work on brinkmate search. Then a new algorithm of brinkmate search is proposed. Finally, the performance results of a brinkmate solver, for which we have implemented the brinkmatesearch algorithm proposed, are shown using a test set of brinkmate problems. 2

What is Brinkmate?

We introduce the concept of brinkmate using the de nitions of threatmate and threat sequence. For clarity, the players are distinguished as an attacker and a defender. De nition 1 A threatmate is a move by the attacker leading to a positon such that the attacker can mate the defender's King at his next move.

De nition 2 A threat sequence is a move or sequence of moves which may contain threatmates or checks by the attacker or responses by the defender to threatmates/checks.

De nition 3 A strong brinkmate is a threat sequence leading to a positon (say P ) such that

1. The defender cannot win at P . 2. The attacker can mate the defender at his next move against any defender's response except a check. 3. The defender may check the attacker during the threat sequence, for which the attacker's response is part of the threat sequence.

1

De nition 4 A weak brinkmate is a threat sequence leading to a positon such that

1. The attacker can mate the defender at his next move against any defender's response except a check. 2. It is assumed that the defender does not check the attacker during the threat sequence.

According to De nition 3, for every defender's response during brinkmate search, the attacker has to examine if; 1. the defender can mate the attacker, or 2. the defender can check the attacker in order to prevent the attacker's threatmate. It is obvious that the search for nding a strong brinkmate will be more expensive than the search for a weak brinkmate, the additional cost depending on the number of checks by the defender during brinkmate search. As a consequence the execution of an algorithm for nding a strong brinkmate will on average be a really time-consuming task. In the following discussion we focus on weak brinkmates and we will further just use the term brinkmate with the meaning of weak brinkmate. We note that brinkmate search with this meaning is still very useful for actual endgame play by computers. 3

Brinkmate-Search Algorithm

The literature concerning brinkmate-search algorithms for chess-like games is rather sparse.1 We are aware only of the work on brinkmate search in Shogi by Yoshikawa [5, 9]. Note that a brinkmate-search algorithm proposed by Yoshikawa presumes several strong heuristics and therefore cannot guarantee the solution. The heuristics used have been implemented mainly in order to reduce the search costs. Note also that the concept of the double threat in qubic [1] and go-moku [2] is related to the brinkmate discussed in this paper, even though these two games are not chess-like games.

3.1 Previous work There are three categories of brinkmate-search algorithms (described below) proposed by Yoshikawa [9], under the assumption that the attacker/defender cannot mate his opponent even when he is to move at a given position. 1. The algorithm of simple-brinkmate roughly is based on choosing some legal move attacking the area around the defender's King, leading to a position such that the attacker can mate after any defender's response not checking the attacker. 2. The algorithm of brinkmate-by-capturing is based on choosing some legal move capturing a piece (Gold, Silver, Knight or Lance) by the attacker's major pieces: Rook or Bishop. This algorithm assumes the defender's re-capture. We note that there is a high probability that the attacker's capturing move is not a threatmate. 3. The algorithm of brinkmate-after-check is based on choosing a check leading to a position such that the attacker can mate irrespective the defender's response. This heuristic may be applied recursively in the sense that the attacker may check the defender not only at a given position but also at positions reached after the defender's response, if necessary. We feel tempted to make some comments on these algorithms of brinkmate search by Yoshikawa. 1

The senior author guesses that most of the programmers of the stronger programs are not inclined to publish details on their brinkmate-search algorithms, since brinkmate search really is a very important part of such programs.

2

1. In the algorithm of simple-brinkmate, not every threatmate candidate necessarily will be investigated, which means that the algorithm has a high probability to miss the solution. 2. The attacker may miss brinkmate at a given position using the algorithm of simple-brinkmate or the algorithm of brinkmate-by-capturing if the position needs more-than-one-step threatmates for brinkmating. 3. Even using the algorithm of brinkmate-after-check there is a high probability to miss the correct path of brinkmating at a given position, since many positions (e.g., brinkmate problems) require several steps as a threat sequence including not only checks but also threatmates. 4. The algorithm of brinkmate-after-check cannot nd a solution starting with a threatmate. However, Yoshikawa's results [5] show that his algorithm (a combination of the three algorithms mentioned) performs very well for the test set given in [6]. This result indicates that:  

The test set used by Yoshikawa mostly consists of brinkmate-with-one-step problems and brinkmateafter-check problems. A search depth of 7 (which is the xed search depth used by Yoshikawa's algorithm for mate search) is deep enough to nd a correct solution for many positions in the test set.

3.2 Brinkmate-with-one-step Let us consider an algorithm of brinkmate-with-one-step, being an algorithm that, at a given position, investigates if there is a threatmate (i.e., a move leading to a position such that the attacker can mate after any defender's response, ignoring eventual checks by the defender). The algorithm of brinkmatewith-one-step forms the basis of the general algorithm of brinkmate to be discussed below. We show, in Figure 1, an algorithm of brinkmate-with-one-step. As shown in Figure 1, the performance of the algorithm of brinkmate-with-one-step will strongly depend on the parameters depth1, depth2 and depth3.2 Here, depth1 denotes the search depth for mate search by the attacker; depth2 denotes the search depth for mate search by the defender when seeking for a response to a threatmate or a check; depth3 denotes the search depth for mate search by the attacker at a position which results after the defender's response. We have some remarks on the brinkmate-with-one-step algorithm. 



 

2

Obviously there is some probability to miss a brinkmate when generating threatmate candidates which can lead to mate within depth1, since it may be necessary to look ahead in mate search by more than depth1. There is some probability to miss a brinkmate even if the attacker generates all legal moves instead of threatmate candidates. It is also necessary to give a proper search depth (depth3) for mate search at a position which will result after a defender's response. Theoretically there is a small probability that in a given position a brinkmate is not a threatmate, in which case the algorithm will miss a correct solution. The parameter depth2 represents the defender's (i.e., opponent's) model. The attacker might suppose a small depth2 against a weaker defender. In the sense of the minimax strategy [7] depth2 should be equal to depth1, while in the sense of OM search [3] depth2 can be smaller than depth1.

We note that in the algorithm by Yoshikawa, the parameters depth1, depth2 and depth3 are xed at 7.

3

brinkmate_with_one_step(int depth1, int depth2, int depth3){ int i,j,m,n,rc; /* generate all the threatmate candidates leading to */ /* positions such that the attacker can mate */ /* at his next move within `depth1' steps. */ n = all_threatmate(depth1); for ( i = 0; i < n; i++ ){ /* play a threatmate candidate in the position */ move_position(threatmateList[i]); /* try to defend against mate within `depth2' steps. */ m = all_defense(depth2); rc = True; for ( j = 0; j < m; j++ ){ move_position(defenseList[j]); /* examine if mate exists within `depth3' steps; */ /* try the next candidate if the defense succeeds */ if((rc = checkmate(depth3))==Fail) break; } /* simple brinkmate succeeds if all defense fails */ if(rc!=Fail) return Brinkmate; } /* simple brinkmate fails if all threatmate candidates fail */ return Fail; }

Figure 1: An algorithm of brinkmate-with-one-step.

3.3 Brinkmate-after-check The algorithm of brinkmate-after-check is also at the basis of a general algorithm of brinkmate. We show, in Figure 2, an algorithm of brinkmate-after-check. This algorithm rst chooses a check, and after the defender's response it chooses a threatmate leading to a position such that the attacker can mate after any defender's response, while ignoring eventual checks by the defender.

3.4 Toward a general algorithm of brinkmate We give a de nition of brinkmate-with-N -steps. De nition 5 A brinkmate-with-N -steps is a weak brinkmate which has N steps, with N an odd natural number > 1.

From the attacker's point of view, the winning sequence of a brinkmate, if it exists, consists of checks and threatmates. For a given brinkmate-with-N -steps problem, the sum of the number of checks and threatmates must be (N + 1)=2. The last move of the sequence must be a threatmate (no check). Hence, the number of combinations of checks and threatmates is given by 2 N201 . For example, there are 32 combinations of checks and threatmates for a brinkmate-with-11-steps problem. In this sense, the algorithms proposed by Yoshikawa may be able to nd a brinkmate for the case N = 1 (simple brinkmate) and a combination of N/2 checks followed by a threatmate. The fraction of brinkmates-with-N -steps that might be solved by Yoshikawa's algorithm is therefore 2=2 N201 .

4

brinkmate_after_check(int depth){ int i,j,m,n,rc; n = all_check(); for ( i = 0; i < n; i++ ){ move_position(checkList[i]); /* try to defend against mate within `depth' steps. */ m = all_defense(depth); rc = True; for ( j = 0; j < m; j++ ){ move_position(defenseList[j]); /* examine if it is a brinkmate-with-one-step */ if((rc=brinkmate_with_one_step(dep1,dep2,dep3))==Fail) break; } /* brinkmate-after-check succeeds if all defense fails */ if(rc!=Fail) return Brinkmate; } /* brinkmate-after-check fails if all checks fail */ return Fail; }

Figure 2: An algorithm of brinkmate-after-check.

General algorithm of brinkmate search by a threat sequence Let us show, in Figure 3, a general algorithm of brinkmate search using a threat sequence (therefore called a threat-sequence-brinkmate), based on the previous two algorithms of simple-brinkmate and brinkmate-after-check. As shown in Figure 3, a general algorithm of brinkmate search is obtained by replacing a check at the attacker's move with a threatmate or check in the standard algorithm of checkmate search [4], whereas the defender's response has to change from a reply to check into a reply to threatmate or check. 4

Experimental Results

We performed some experiments to show some performance results by our brinkmate solver in which the algorithm of threat-sequence-brinkmate search was implemented. First we explain the experimental design, then show some results on a set of brinkmate problems. We next investigate the relation between mate-search depth and the number of threatmate candidates, and nally we discuss the search eciency.

4.1 Experimental design A test set of brinkmate problems [8] has been used for some experiments to show the performance of the brinkmate algorithm proposed in this paper. The test set contains 39 brinkmate problems: 8 problems with one step, 19 with three steps, 10 with ve steps and 2 with seven steps, where the number of steps are as intended by the composer (however, see below). For each problem, our brinkmate solver rst tried to nd a solution of brinkmate-with-N -steps for N  7.

5

threat_sequence_brinkmate(int dep1, dep2, dep3){ int i, j, m, n; if (dep2 < 1 ) return fail; if (checkmate(dep3) == true) return brinkmate; /* generate all the threatmate candidates plus checks */ /* leading to positions such that the attacker can mate */ /* at his next move within `depth1' steps. */ n = generate_threat_sequence(dep1); for ( i = 0; i < n; i++ ){ move_position(threatseuqencelist[i]); m = all_defense(dep2); for ( j = 0; j < m; j++ ){ move_position(defenselist[j]); if ((rc = threat_sequence_brinkmate(dep1,dep2-2,dep3)) == fail ) break; } /* threat-sequence-brinkmate succeeds if all defense fails */ if (rc!=fail) return brinkmate; } /* threat-sequence-brinkmate fails if all threatmate candidates fail */ return fail; }

Figure 3: An algorithm of threat-sequence-brinkmate.

4.2 Results on problem solving by the algorithm proposed We show in Table 1 results on problem-solving performance by our brinkmate solver. The depth for mate search, to nd both the attacker's threatmate candidates and the defender's responses to threatmates and checks, was xed at 7, whereas depths varying from 1 to 15 were used for mate search at a leaf node in the search tree. no. 1 2 3 4 5 6 7 8 9 10 11 12 13

step 1 1 1 1 1 1 3 1 3 3 3 3 5

type T T T T T T TT T CT CT TT TT CTT

no. 14 15 16 17 18 19 20 21 22 23 24 25 26

step 5 3 3 11 7 3 3 3 3 3

type CTT TT CT TTTTTT CTTT CT CT TT TT CT

3 3

TT CT

no. 27 28 29 30 31 32 33 34 35 36 37 38 39

step 3 5 5 5 5

type TT CTT CCT CCT CCT

5 5 5 9 5 7 15

TCT TTT CCT TTTTT CCT CCTT CTTTTTCT

Table 1: Performance results on brinkmate problems.

The `step' represents the number of steps found for each problem. The `type' represents the combination of the type of attacker's moves: a threatmate being denoted as `T' and a check being denoted as `C'. Note that some problems require more steps than the intention of the composer. No. 24 and no. 32 are incomplete problems.

From the results we see that: 

Some problems (no. 7, 13, 14, 17, 18, 36, and 39) cannot be solved within the number of steps as intended by the composer. 6

 

Our brinkmate solver was able to point out two errors, i.e., that no. 24 and no. 32 have no solution (incomplete problems). For no. 17, 18, 36, and 39 we performed further experiments with a larger mate-search depth, by which our brinkmate solver was able to nd a solution.

4.3 Mate-search depth and the number of threatmate candidates In Table 2 we show the relation between the mate-search depth and the number of threatmate candidates generated by the brinkmate solver. At a given position of each problem, the brinkmate solver tried to generate threatmate candidates for varying mate-search depths. depth 1 3 5 7 9 11 13 15

no. 1 0 5 12 12 12 12 12 12

no. 2 4 5 6 6 6 6 6 6

no. 3 1 2 2 2 2 2 2 2

no. 4 2 8 8 8 8 8 8 8

no. 5 9 13 13 13 13 13 13 13

no. 6 2 2 4 6 6 6 6 6

no. 7 3 3 4 4 4 4 4 4

no. 8 2 2 2 2 5 14 14 14

Table 2: Mate-search depth and the number of threatmate candidates.

The `depth' represents the mate-search depth used to generate threatmate candidates. The number for each problem (no. 1 to no. 8), shown in the columns, represents how many threatmate candidates can be generated by the solver for the various search depths (1 to 15).

Table 2 indicates that:  



As the mate-search depth increases, the number of threatmate candidates becomes larger, which may correspond to that the probability to miss a correct solution will decrease. For most problems, mate-search depth 7 is large enough to generate threatmate candidates which may contain the correct one, although some problems (see no. 8 in the table) need a much larger depth. In brinkmate search the diculty of a brinkmate problem depends on the depth which may be required to contain a solution among the threatmate candidates.

4.4 Towards search eciency We see that the general algorithm of brinkmate search is an expensive algorithm, in other words, solving a brinkmate problem is a really time-consuming task. It is obvious that the task of brinkmate search is much more dicult than that of simple mate search. We discuss shortly the costs of brinkmate search and then consider search eciency. Search costs

The search costs can be measured by the number of calls to the mate-search module. In brinkmate search, both the attacker and the defender call the mate-search module in order to generate a threat sequence. Let us show, in Table 3, some examples of brinkmate-search cost. 7

depth 1 3 5 7 9

no. 1 82 99 207 589 590

no. 2 151 156 156 163 168

no. 3 95 752 752 752 752

no. 4 103 545 563 563 563

no. 5 156 561 552 546 555

no. 6 443 460 460 460 463

no. 7 119 129 166 168 168

no. 8 47 83 84 84 89

Table 3: Some examples of brinkmate-search cost.

The `depth' denotes the mate-search depth. The numbers shown in the table represent the number of calls to the mate-search module for various mate-search depths.

Table 3 reveals that:  



As the mate-search depth increases, which means that the number of threatmate candidates becomes much larger, the number of calls to the mate-search module increases also. Assuming that we use a mate-search depth xed at 7, the number of calls to the mate-search module is approximately 400 on average. This means that even solving a one-step brinkmate problem takes on average about 400 times longer as a mate search. For most cases depth 7 is deep enough to generate enough threatmate candidates.

Another preliminary experiment revealed that there is no signi cant di erence in search cost between the following two methods to extend nodes in brinkmate search for one-step brinkmate problems: (1) to generate only a threat sequence and (2) to generate all possible moves. This stems from the fact that AND/OR tree search generates cuto s both when all moves are extended in brinkmate search, as well as when the algorithm uses a threat sequence. To investigate this claim in more detail we have done some additional experiments illustrated in Table 4, using an example of search cost for more-than-three-steps brinkmate problems. no. 9 10 11 12 13 14 15 16 17 18

all moves 318 13,014 1,311 11,863 17,944 12,873 2,579 466 3,985 6,766

threat sequence 394 3,938 1,369 1,250 1,132 1,825 833 558 908 330

no. 19 20 21 22 23 24 25 26 27

all moves 381 930 1,038 1,439 467 35,251 2,885 388 2,171

threat sequence 503 913 709 620 470 4,024 1,624 438 1,147

Table 4: A comparison of search costs.

The numbers shown in the table represent the number of calls to the mate-search modules. The problems no. 9 to no. 27, composed as three-steps problems, were used for the experiments.

Table 4 indicates that: 

For each problem whose solution consists of a check and a threatmate (in that order) from the attacker's point of view (see no. 9, 16, 19, 20, 23, and 26, denoted by `CT' in Table 1), there is no signi cant di erence in search cost between the two methods investigated. More generally, we expect that problems whose solution contains some checks and a threatmate (like problems denoted `CCT' in Table 1) still have this property. 8



5

For other types of brinkmate problems it is better to use the algorithm using a threat sequence as in our brinkmate solver than the algorithm extending all moves. Conclusions

This research reports on a brinkmate-search algorithm together with some experimental results. The brinkmate solver can solve all the complete problems of a test set [8] of brinkmate problems with more than two steps, whose solution contains more than two threatmates by the attacker. The brinkmate solver also found that the test set [8] used in the experiment contains nine incomplete problems, in the sense that seven of them require more steps to solve than the composer's intention, whereas the other two are really incomplete. Our results suggest that there is some potential for a better eciency of brinkmate search, e.g., by extending checks before threatmates at the attacker's moves during brinkmate search. Our next target is to solve long-steps brinkmate problems within reasonable time and to compose a brinkmate problem. Acknowledgements

This work has bene tted from research discussions in CSA and especially with Yuzuru Hiraga and dr. Hitoshi Matsubara. The nancial support of the Foundation for Fusion of Science & Technology (FOST) is gratefully acknowledged. The authors are duly grateful for a scrutiny-in-depth of previous version of this paper by dr. J.W.H.M. Uiterwijk. Any remaining errors, however, are the authors'. References

[1] Allis, L.V. and Schoo, P.N.A. (1992). Qubic Solved Again. Heuristic Programming in Arti cial Intelligence 3: the third computer olympiad (eds. H.J. Van den Herik and L.V. Allis), pp. 192{204. Ellis Horwood, Chichester, England. [2] Allis, L.V., Herik, H.J. van den and Huntjens, M.P.H. (1993). Go-Moku Solved by New Search Techniques. Proceedings of the 1993 AAAI Fall Symposium on Games: Planning and Learning. Technical Report FS93-02. AAAI Press, Menlo Park, CA. [3] Iida, H., Uiterwijk, J.W.H.M., Herik, H.J. van den and Herschberg, I.S. (1993). Potential Applications of Opponent-Model Search. Part 1. The domain of applicability. ICCA Journal, Vol. 16, No. 4, pp. 201{208. [4] Itoh, T., Kawano, Y., Seo, M. and Noshita, K. (1995). Recent Progress in Solving Tsume-Shogi by Computers. Journal of Japanese Society for Arti cial Intelligence, Vol.10, No. 6, pp. 116{122. (in Japanese) [5] Kotani, Y., Yoshikawa, T., Kakinoki, Y. and Morita, K. (1990). Computer Shogi. Science Press. (in Japanese) [6] Maeda, Y. Brinkmate Problems 100. Sankaido. [7] Neumann, J. von (1928). Zur Theorie der Gesellschaftsspiele. Math. Ann., Vol. 100, pp. 295{320. Reprinted (1963) in John von Neumann Collected Works (ed. A.H. Taub), Vol. VI, pp. 1{26. Pergamon Press, Oxford. 9

[8] Sato, D. (1995). Brinkmate Problems 39 for your lookahead practice. Shogi World Magazine Appendix, Vol. 59, No. 8. Japanese Shogi Association. [9] Yoshikawa, T. (1987). A Study of Shogi Program. Programmer's 6, Vol. 3, pp.102{115. GijutsuHyoron Press. (in Japanese)

10

Suggest Documents