moveStackRejections.h
Go to the documentation of this file.
00001 /* moveStackRejections.h
00002  */
00003 #ifndef _MOVE_STACK_REJECTIONS_H
00004 #define _MOVE_STACK_REJECTIONS_H
00005 #include "osl/state/numEffectState.h"
00006 #include "osl/container/moveStack.h"
00007 #include "osl/misc/carray.h"
00008 #include <iosfwd>
00009 
00010 namespace osl
00011 {
00012   namespace search
00013   {
00018     struct OnBoardElement {
00019       short posPtypeO;
00020       OnBoardElement() {}
00021       OnBoardElement(Square pos_,PtypeO ptypeO_){
00022         posPtypeO=makePosPtypeO(pos_,ptypeO_);
00023       }
00024       static short makePosPtypeO(Square pos,PtypeO ptypeO)
00025       {
00026         return static_cast<short>(pos.uintValue()+(ptypeO<<8));
00027       }
00028       Square pos() const{
00029         return Square::makeDirect(posPtypeO&0xff);
00030       }
00031       PtypeO ptypeO() const{
00032         return static_cast<PtypeO>(posPtypeO>>8);
00033       }
00034     };
00039     struct StandElements {
00040       union {
00041         CArray<char,8> c8;
00042         unsigned long long l8;
00043       } v;
00044       StandElements() { v.l8=0x8080808080808080ull; }
00048       void add(Ptype ptype){
00049         assert(ptype>=PTYPE_BASIC_MIN);
00050         v.c8[ptype-PTYPE_BASIC_MIN]++;
00051       }
00055       void sub(Ptype ptype){
00056         assert(ptype>=PTYPE_BASIC_MIN);
00057         v.c8[ptype-PTYPE_BASIC_MIN]--;
00058       }
00059       bool isZero() const{
00060         return v.l8==0x8080808080808080ull;
00061       }
00062       bool gtZero() const{
00063         return !isZero() && geZero();
00064       }
00065       bool geZero() const{
00066         return (v.l8&0x8080808080808080ull)==0x8080808080808080ull;
00067       }
00068     };
00076     struct StateElements {
00077       FixedCapacityVector<OnBoardElement,32> myOnboardPlus;
00078       FixedCapacityVector<OnBoardElement,32> opOnboardPlus;
00079       FixedCapacityVector<OnBoardElement,64> myOnboardMinus;
00080       FixedCapacityVector<OnBoardElement,64> opOnboardMinus;
00081       StandElements stand;
00082     public:
00083       StateElements() {
00084       }
00085       void clear() {
00086       }
00091       void addStand(Ptype ptype);
00096       void subStand(Ptype ptype);
00100       void addMyBoard(Square pos,PtypeO ptypeO);
00101       void subMyBoard(Square pos,PtypeO ptypeO);
00102       void addOpBoard(Square pos,PtypeO ptypeO);
00103       void subOpBoard(Square pos,PtypeO ptypeO);
00107       void addMyMove(Move move);
00111       void addOpMove(Move move);
00115       bool isLoop() const{
00116         return myOnboardPlus.size()==0 && opOnboardPlus.size()==0 &&
00117           myOnboardMinus.size()==0 && opOnboardMinus.size()==0;
00118       }
00122       template<Player P>
00123       bool validSimpleMove(NumEffectState const& state,OnBoardElement const& fromElement,OnBoardElement const& toElement) const;
00128       template<Player P>
00129       bool validSimpleMove(NumEffectState const& state,OnBoardElement const& fromElement,OnBoardElement const& toElement,Move lastMove) const;
00133       template<Player P>
00134       bool validCaptureMove(NumEffectState const& state, OnBoardElement const& fromElement,OnBoardElement const& toElement,OnBoardElement const& captureElement) const;
00139       template<Player P>
00140       bool validCaptureMove(NumEffectState const& state, OnBoardElement const& fromElement,OnBoardElement const& toElement,OnBoardElement const& captureElement,Move lastMove) const;
00157       template<Player P>
00158       bool canReject(NumEffectState const& state,bool mayRejectSennichite,bool isRootMove,Move lastMove,Move actualMove) const;
00159     };
00160     std::ostream& operator<<(std::ostream&,OnBoardElement const&);
00161     std::ostream& operator<<(std::ostream&,StandElements const&);
00162     std::ostream& operator<<(std::ostream&,StateElements const&);
00163     class MoveStackRejections
00164     {
00165     public:
00175       template<Player P>
00176       static bool probe(NumEffectState const& state,MoveStack const& history,int ply,Move const& m,int alpha, int checkCountOfAltP);
00177     };
00178   }
00179 }
00180 #endif /* _MOVE_STACKREJECTIONS_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines