00001
00002
00003 #ifndef SEARCH_DOMINANCECHECK_H
00004 #define SEARCH_DOMINANCECHECK_H
00005
00006 #include "osl/hash/hashKeyStack.h"
00007 namespace osl
00008 {
00009 namespace search
00010 {
00011 struct DominanceCheck
00012 {
00013 enum Result { NORMAL=0, WIN, LOSE };
00020 static Result detect(const HashKeyStack& history,
00021 const HashKey& next_state)
00022 {
00023 const Player player = alt(next_state.turn());
00024 const PieceStand new_stand = next_state.blackStand();
00025 for (size_t i=3; i<history.size(); i+=4)
00026 {
00027
00028 const HashKey& old_state = history.top(i);
00029 assert(old_state.turn() == next_state.turn());
00030 if (! old_state.isSameBoard(next_state))
00031 continue;
00032
00033 const PieceStand old_stand = old_state.blackStand();
00034 if (old_stand == new_stand)
00035 return NORMAL;
00036 if (old_stand.hasMoreThan(player, new_stand))
00037 return LOSE;
00038 if (new_stand.hasMoreThan(player, old_stand))
00039 return WIN;
00040 }
00041 return NORMAL;
00042 }
00043 };
00044 }
00045 }
00046
00047
00048 #endif
00049
00050
00051
00052