sacrificeCheck.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sacrificeCheck.h
Go to the documentation of this file.
1 /* sacrificeCheck.h
2 */
3 #ifndef OSL_SACRIFICECHECK_H
4 #define OSL_SACRIFICECHECK_H
5
6 #include "osl/search/simpleHashRecord.h"
7 #include "osl/container/moveStack.h"
8
9 namespace osl
10 {
11 namespace search
12 {
13 struct SacrificeCheck
14 {
15 template<class RecordStack>
16 static int count2(const RecordStack& record_stack,
17 const MoveStack& history,
18 int history_max)
19 {
20 int i=1;
21 while (history.hasLastMove(i+1) && (i+1 <= history_max))
22 {
23 // 王手回避で駒得
24 assert(record_stack.hasLastRecord(i));
25 const SimpleHashRecord *last_record = record_stack.lastRecord(i);
26 if ((! last_record) || (! last_record->inCheck()))
27 break;
28 const Move last_move = history.lastMove(i);
29 if (! last_move.isCapture())
30 break;
31 if (static_cast<int>(record_stack.size()) <= i)
32 break;
33 // ただで取られた王手
34 const Move last_last_move = history.lastMove(i+1);
35 if ((last_last_move.to() != last_move.to())
36 || (last_last_move.isCapture())
37 || (unpromote(last_last_move.ptype()) == PAWN))
38 break;
39 i+=2;
40 }
41 return i/2;
42 }
43 };
44 } // namespace search
45 } // namespace osl
46
47 #endif /* OSL_SACRIFICECHECK_H */
48 // ;;; Local Variables:
49 // ;;; mode:c++
50 // ;;; c-basic-offset:2
51 // ;;; End: