All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
moveStackRejections.h
Go to the documentation of this file.
1 /* moveStackRejections.h
2  */
3 #ifndef _MOVE_STACK_REJECTIONS_H
4 #define _MOVE_STACK_REJECTIONS_H
7 #include "osl/misc/carray.h"
8 #include <iosfwd>
9 
10 namespace osl
11 {
12  namespace search
13  {
18  struct OnBoardElement {
19  short posPtypeO;
21  OnBoardElement(Square pos_,PtypeO ptypeO_){
22  posPtypeO=makePosPtypeO(pos_,ptypeO_);
23  }
25  {
26  return static_cast<short>(pos.uintValue()+(ptypeO<<8));
27  }
28  Square pos() const{
29  return Square::makeDirect(posPtypeO&0xff);
30  }
31  PtypeO ptypeO() const{
32  return static_cast<PtypeO>(posPtypeO>>8);
33  }
34  };
39  struct StandElements {
40  union {
41  CArray<char,8> c8;
42  unsigned long long l8;
43  } v;
44  StandElements() { v.l8=0x8080808080808080ull; }
48  void add(Ptype ptype){
49  assert(ptype>=PTYPE_BASIC_MIN);
50  v.c8[ptype-PTYPE_BASIC_MIN]++;
51  }
55  void sub(Ptype ptype){
56  assert(ptype>=PTYPE_BASIC_MIN);
57  v.c8[ptype-PTYPE_BASIC_MIN]--;
58  }
59  bool isZero() const{
60  return v.l8==0x8080808080808080ull;
61  }
62  bool gtZero() const{
63  return !isZero() && geZero();
64  }
65  bool geZero() const{
66  return (v.l8&0x8080808080808080ull)==0x8080808080808080ull;
67  }
68  };
76  struct StateElements {
77  FixedCapacityVector<OnBoardElement,32> myOnboardPlus;
78  FixedCapacityVector<OnBoardElement,32> opOnboardPlus;
79  FixedCapacityVector<OnBoardElement,64> myOnboardMinus;
80  FixedCapacityVector<OnBoardElement,64> opOnboardMinus;
82  public:
84  }
85  void clear() {
86  }
91  void addStand(Ptype ptype);
96  void subStand(Ptype ptype);
100  void addMyBoard(Square pos,PtypeO ptypeO);
101  void subMyBoard(Square pos,PtypeO ptypeO);
102  void addOpBoard(Square pos,PtypeO ptypeO);
103  void subOpBoard(Square pos,PtypeO ptypeO);
107  void addMyMove(Move move);
111  void addOpMove(Move move);
115  bool isLoop() const{
116  return myOnboardPlus.size()==0 && opOnboardPlus.size()==0 &&
117  myOnboardMinus.size()==0 && opOnboardMinus.size()==0;
118  }
122  template<Player P>
123  bool validSimpleMove(NumEffectState const& state,OnBoardElement const& fromElement,OnBoardElement const& toElement) const;
128  template<Player P>
129  bool validSimpleMove(NumEffectState const& state,OnBoardElement const& fromElement,OnBoardElement const& toElement,Move lastMove) const;
133  template<Player P>
134  bool validCaptureMove(NumEffectState const& state, OnBoardElement const& fromElement,OnBoardElement const& toElement,OnBoardElement const& captureElement) const;
139  template<Player P>
140  bool validCaptureMove(NumEffectState const& state, OnBoardElement const& fromElement,OnBoardElement const& toElement,OnBoardElement const& captureElement,Move lastMove) const;
157  template<Player P>
158  bool canReject(NumEffectState const& state,bool mayRejectSennichite,bool isRootMove,Move lastMove,Move actualMove) const;
159  };
160  std::ostream& operator<<(std::ostream&,OnBoardElement const&);
161  std::ostream& operator<<(std::ostream&,StandElements const&);
162  std::ostream& operator<<(std::ostream&,StateElements const&);
164  {
165  public:
175  template<Player P>
176  static bool probe(NumEffectState const& state,MoveStack const& history,int ply,Move const& m,int alpha, int checkCountOfAltP);
177  };
178  }
179 }
180 #endif /* _MOVE_STACKREJECTIONS_H */
181 // ;;; Local Variables:
182 // ;;; mode:c++
183 // ;;; c-basic-offset:2
184 // ;;; End: