-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaskableMove.cpp
More file actions
68 lines (55 loc) · 1.84 KB
/
Copy pathaskableMove.cpp
File metadata and controls
68 lines (55 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "stockfish_src/uci.h"
#include "stockfish_src/thread.h"
#include "stockfish_src/search.h"
#include "stockfish_src/position.h"
#include "askableMove.h"
#include "askablePiece.h"
#include "askablePosition.h"
using namespace Stockfish;
AskableMove::AskableMove(Move m, AskablePosition* posFrom) {
this->sfMove = m;
this->from = posFrom;
}
void AskableMove::debug() const {
cerr << UCI::move(this->sfMove, false);
if (color_of(from->piece_on(from_sq(sfMove))) == from->side_to_move()) {cerr << " ctLost: " << this->centipawnsLost(); }
cerr << " capturing hanging piece: " << this->captureHangingPiece();
cerr << " isSEEPositiveCapture: " << this->isSEEPositiveCapture() << endl;
}
int AskableMove::centipawnsLost() const {
/*
* caveat : doesn't work well with castling moves.
*/
Options["MultiPV"] = to_string(1);
AskableMove bestMove = from->getNBestMoves(1)[0];
if (bestMove.sfMove == this->sfMove) {
return 0;
}
int bestScore = from->this_thread()->rootMoves[0].score;
Search::LimitsType limits;
limits.searchmoves.push_back(this->sfMove);
from->limitedSearch(limits);
return bestScore - from->this_thread()->rootMoves[0].score;
}
bool AskableMove::captureHangingPiece() const {
if (from->capture(sfMove)) {
AskablePiece p = AskablePiece(from->piece_on(to_sq(sfMove)), to_sq(sfMove), from);
return p.isHanging();
}
return false;
}
bool AskableMove::isSEEPositiveCapture() const {
/*
* Simply use Stockfish `Position` method with value 1 because Stockfish method
* returns true if greater or equal and use 0 as default threshold.
*/
return from->see_ge(this->sfMove, Value(1));
}
/*
bool AskableMove::allowOppSEEPositiveCapture() {
}
bool AskableMove::allowOppGoodMove() {
}
bool AskableMove::allowOppGoodMoveUndefending() {
}
*/