All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
moveInfo.cc
Go to the documentation of this file.
1 /* moveInfo.cc
2  */
7 #include "osl/eval/see.h"
8 #include "osl/eval/ml/minorPiece.h" // todo
9 using namespace osl::move_classifier;
10 
13  : move(m),
14  see(See::see(*info.state, move, info.pin[info.state->turn()],
15  info.pin[alt(info.state->turn())])),
16  plain_see(see),
17  check(PlayerMoveAdaptor<Check>::isMember(*info.state, move)),
18  open_check(ConditionAdaptor<OpenCheck>::isMember(*info.state, move)),
19  player(m.player()), stand_index_cache(-1)
20 {
21  // ad-hoc adjustment
22  if (adhocAdjustBishopFork(info))
23  see = 0;
24  else if (adhocAdjustSlider(info))
25  see = plain_see / 8;
26  else if (adhocAdjustBreakThreatmate(info))
27  see = 0;
29  see = 0;
30  else if (adhocAdjustKeepCheckmateDefender(info))
31  see = 0;
32 }
33 
36 {
37  if (plain_see >= 0)
38  return false;
39  const Piece attack = info.state->findCheapAttack(alt(player), move.to());
40  return info.pinByOpposingSliders(attack)
41  && (move.isDrop()
42  || ! info.state->hasEffectByPiece(info.state->pieceAt(move.from()),
43  attack.square()));
44 }
45 
48 {
49  if (plain_see >= 0
50  || !info.state->hasPieceOnStand<BISHOP>(info.state->turn()))
51  return false;
52 
53  const Piece attack
54  = info.state->findCheapAttack(alt(player), move.to());
55  if (unpromote(attack.ptype()) == ROOK) {
56  const Player defense = alt(info.state->turn());
57  const Square king = info.state->kingSquare(defense);
58  const Square center
59  = eval::ml::BishopRookFork::isBishopForkSquare(*info.state, defense, king, move.to(), true);
60  return ! center.isPieceStand();
61  }
62  return false;
63 }
64 
67 {
68  if (! info.threatmate_move.isNormal())
69  return false;
70 
71  const Piece attack
72  = info.state->findCheapAttack(alt(player), move.to());
73  if (attack.isPiece() // break threatmate by sacrifice
74  && info.state->hasEffectByPiece(attack, info.threatmate_move.to()))
75  return ! info.state->hasEffectIf(attack.ptypeO(), move.to(),
76  info.threatmate_move.to());
77  return false;
78 }
79 
82 {
83  if (plain_see >= 0)
84  return false;
85  const Piece defender = info.checkmate_defender[alt(player)].first;
86  if (defender.isPiece()
87  && info.state->countEffect(alt(player), move.to()) == 1
88  && info.state->hasEffectByPiece(defender, move.to()))
89  return true;
90  return false;
91 }
92 
95 {
96  if (plain_see <= 0)
97  return false;
98  const Piece defender = info.checkmate_defender[player].first;
99  const Square threat_at = info.checkmate_defender[player].second;
100  if (defender.isPiece() && move.from() == defender.square()
101  && ! info.state->hasEffectIf(move.ptypeO(), move.to(), threat_at))
102  return true;
103  return false;
104 }
105 
106 // ;;; Local Variables:
107 // ;;; mode:c++
108 // ;;; c-basic-offset:2
109 // ;;; End: