All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
signatureEffect.h
Go to the documentation of this file.
1 #ifndef _SIGNATURE_EFFECT_H
2 #define _SIGNATURE_EFFECT_H
3 
5 #include "osl/piece.h"
6 #include "osl/misc/carray.h"
7 
8 namespace osl
9 {
10  namespace effect
11  {
16  CArray<MoveSignature,16*(9+4)> signatures;
17  public:
18  template<typename State>
20  std::fill(signatures.begin(),signatures.end(),signature_EDGE);
21  for(int y=1;y<=9;y++)
22  for(int x=1;x<=9;x++){
23  Square pos(x,y);
24  PtypeO ptypeO=getPtypeO(state.pieceAt(pos));
26  }
27  }
28  MoveSignature get(Square pos) const{
29  return signatures[pos.index()];
30  }
31  void set(Square pos,MoveSignature signature){
32  signatures[pos.index()]=signature;
33  }
34  };
35 
36  template <Player P,class State>
38  template <Player P,class State>
40  template <Player P,class State>
42 
49  template<class State>
50  class SignatureEffect: public State{
51  public:
55  public:
56  template<typename OrigState>
57  explicit SignatureEffect(OrigState const& st) :State(st),signatureTable(st){}
59  return signatureTable.get(pos);
60  }
61  void setSignature(Square pos,MoveSignature signature){
62  signatureTable.set(pos,signature);
63  }
64  };
65 
66  template<Player P,typename BaseState>
67  struct ApplyDoUndoSimpleMove<P,SignatureEffect<BaseState> >
68  {
70  template <typename F>
71  static void doUndoSimpleMove(state_t& s,
72  Square from, Square to, int promoteMask,F& func){
73  /* signatureのset */
74  Piece oldPiece=s.pieceAt(from);
75  PtypeO ptypeO=oldPiece.promoteWithMask(promoteMask).ptypeO();
76  MoveSignature oldSignature=s.getSignature(from);
79 
80  ApplyDoUndoSimpleMove<P,BaseState>::doUndoSimpleMove(s,from,to,promoteMask,func);
81 
82  /* signatureの書き戻し */
83  s.setSignature(from,oldSignature);
85  }
86  };
87 
88  template<Player P,typename BaseState>
89  struct ApplyDoUndoDropMove<P,SignatureEffect<BaseState> >
90  {
92  template <typename F>
93  static void doUndoDropMove(state_t& s,
94  Square to, Ptype ptype,F& func){
95  /* signatureのset */
96  PtypeO ptypeO=newPtypeO(P,ptype);
98 
100  /* signatureのundo */
102 
103  }
104  };
105 
106  template<Player P,typename BaseState>
108  {
110  template <typename F>
111  static void doUndoCaptureMove(state_t& s,
112  Square from,Square to, Piece p1, int promoteMask,F& func){
113  /* signatureのset */
114  Piece oldPiece=s.pieceAt(from);
115  PtypeO ptypeO=oldPiece.promoteWithMask(promoteMask).ptypeO();
116  MoveSignature oldSignatureFrom=s.getSignature(from);
118  MoveSignature oldSignatureTo=s.getSignature(to);
120  /* base classの呼び出し */
121  ApplyDoUndoCaptureMove<P,BaseState>::doUndoCaptureMove(s,from,to,p1,promoteMask,func);
122  /* signatureの書き戻し */
123  s.setSignature(from,oldSignatureFrom);
124  s.setSignature(to,oldSignatureTo);
125  }
126  };
127 } // namespace effect
128 } // namespace osl
129 #endif // _SIGNATURE_EFFECT_H
130 // ;;; Local Variables:
131 // ;;; mode:c++
132 // ;;; c-basic-offset:2
133 // ;;; End: