00001 /* sacrificeCheck.h 00002 */ 00003 #ifndef OSL_SACRIFICECHECK_H 00004 #define OSL_SACRIFICECHECK_H 00005 00006 #include "osl/search/simpleHashRecord.h" 00007 #include "osl/container/moveStack.h" 00008 00009 namespace osl 00010 { 00011 namespace search 00012 { 00013 struct SacrificeCheck 00014 { 00015 template<class RecordStack> 00016 static int count2(const RecordStack& record_stack, 00017 const MoveStack& history, 00018 int history_max) 00019 { 00020 int i=1; 00021 while (history.hasLastMove(i+1) && (i+1 <= history_max)) 00022 { 00023 // Ƕ 00024 assert(record_stack.hasLastRecord(i)); 00025 const SimpleHashRecord *last_record = record_stack.lastRecord(i); 00026 if ((! last_record) || (! last_record->is_king_in_check)) 00027 break; 00028 const Move last_move = history.lastMove(i); 00029 if (last_move.capturePtype() == PTYPE_EMPTY) 00030 break; 00031 if (static_cast<int>(record_stack.size()) <= i) 00032 break; 00033 // Ǽ줿 00034 const Move last_last_move = history.lastMove(i+1); 00035 if ((last_last_move.to() != last_move.to()) 00036 || (last_last_move.capturePtype() != PTYPE_EMPTY) 00037 || (unpromote(last_last_move.ptype()) == PAWN)) 00038 break; 00039 i+=2; 00040 } 00041 return i/2; 00042 } 00043 }; 00044 } // namespace search 00045 } // namespace osl 00046 00047 #endif /* OSL_SACRIFICECHECK_H */ 00048 // ;;; Local Variables: 00049 // ;;; mode:c++ 00050 // ;;; c-basic-offset:2 00051 // ;;; End: