All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
legalMoves.cc
Go to the documentation of this file.
1 /* legalMoves.cc
2  */
11 #include <boost/foreach.hpp>
12 
14 LegalMoves::generate(const NumEffectState& state, MoveVector& moves)
15 {
16  if (state.inCheck())
17  {
18  // 王手がかかっている時は防ぐ手のみを生成, 王手回避は不成も生成
19  GenerateEscapeKing::generate(state, moves);
20  }
21  else
22  {
23  // そうでなければ全ての手を生成
24  MoveVector all_moves;
25  GenerateAllMoves::generate(state.turn(), state, all_moves);
26  // この指手は,玉の素抜きがあったり,打歩詰の可能性があるので
27  // 確認が必要
28  using namespace osl::move_classifier;
29  BOOST_FOREACH(Move m, all_moves)
30  {
31  if (m.isDrop()
33  {
35  {
36  moves.push_back(m);
37  }
38  }
39  }
40  }
41 }
42 
44 LegalMoves::generateWithFullUnpromotions(const NumEffectState& state,
45  MoveVector& moves)
46 {
47  generate(state, moves);
48  if (state.inCheck())
49  return;
50  for (int i=0, iend=moves.size(); i<iend; ++i) {
51  const osl::Move move = moves[i];
52  if (move.hasIgnoredUnpromote())
53  moves.push_back(move.unpromote());
54  }
55 }
56 
57 // ;;; Local Variables:
58 // ;;; mode:c++
59 // ;;; c-basic-offset:2
60 // ;;; End: