00001
00002
00003 #ifndef OSL_CHECKMATE_KING8INFO_H
00004 #define OSL_CHECKMATE_KING8INFO_H
00005
00006 #include "osl/state/numEffectState.h"
00007 #include "osl/misc/bitOp.h"
00008 #include <iosfwd>
00009 namespace osl
00010 {
00011 namespace checkmate
00012 {
00023 struct King8Info
00024 {
00025 unsigned int value;
00026 explicit King8Info(unsigned int v) : value(v)
00027 {
00028 }
00029
00030 template<Player P>
00031 static const King8Info make(NumEffectState const& state,Position king,PieceMask pinned);
00032 template<Player P>
00033 static const King8Info make(NumEffectState const& state,Position king);
00034
00036 static const King8Info make(Player attack, NumEffectState const& state);
00038 static const King8Info makeWithPin(Player attack, NumEffectState const& state,
00039 const PieceMask& pinned);
00040
00042 unsigned int dropCandidate() const
00043 {
00044 return value&0xff;
00045 }
00047 unsigned int liberty() const
00048 {
00049 return (value>>8)&0xff;
00050 }
00051 unsigned int libertyCount() const
00052 {
00053 return misc::BitOp::countBit(liberty());
00054 }
00056 unsigned int libertyDropMask() const
00057 {
00058 return value&0xffff;
00059 }
00061 unsigned int libertyCandidate() const
00062 {
00063 return (value>>16)&0xff;
00064 }
00066 unsigned int moveCandidate() const
00067 {
00068 return (value>>24)&0xff;
00069 }
00070 private:
00078 template<Player P,Direction Dir>
00079 static unsigned int hasEffectMask(NumEffectState const& state,Position target,PieceMask pinned);
00080 };
00081
00082 std::ostream& operator<<(std::ostream&, King8Info);
00083 }
00084 using checkmate::King8Info;
00085 }
00086
00087 #endif
00088
00089
00090
00091
00092