evaluate: MOBILITY: Modify implement (WIP)
No improvement now. Keep Disabling it.
This commit is contained in:
parent
8d7eaf57c6
commit
a0aacae1fc
|
@ -25,6 +25,8 @@
|
|||
#pragma execution_character_set("utf-8")
|
||||
#endif
|
||||
|
||||
//#define EVALUATE_MOBILITY
|
||||
|
||||
//#undef QT_GUI_LIB
|
||||
|
||||
//#define UCI_AUTO_RE_GO
|
||||
|
|
|
@ -87,10 +87,7 @@ Value Evaluation::value()
|
|||
value = (pos.piece_on_board_count(BLACK) - pos.piece_on_board_count(WHITE)) * VALUE_EACH_PIECE_ONBOARD;
|
||||
|
||||
#ifdef EVALUATE_MOBILITY
|
||||
value += pos.get_mobility_diff(position->turn,
|
||||
position->pieceInHandCount[BLACK],
|
||||
position->pieceInHandCount[WHITE],
|
||||
false) * 10;
|
||||
value += pos.get_mobility_diff() / 5;
|
||||
#endif /* EVALUATE_MOBILITY */
|
||||
|
||||
switch (pos.get_action()) {
|
||||
|
|
|
@ -1018,27 +1018,30 @@ bool Position::check_if_game_is_over()
|
|||
return false;
|
||||
}
|
||||
|
||||
int Position::get_mobility_diff(bool includeBanned)
|
||||
int Position::get_mobility_diff()
|
||||
{
|
||||
// TODO: Deal with rule is no ban location
|
||||
int mobilityBlack = 0;
|
||||
int mobilityWhite = 0;
|
||||
int diff = 0;
|
||||
int n = 0;
|
||||
|
||||
for (Square i = SQ_BEGIN; i < SQ_END; ++i) {
|
||||
n = surrounded_empty_squares_count(i, includeBanned);
|
||||
|
||||
if (board[i] & B_STONE) {
|
||||
mobilityBlack += n;
|
||||
} else if (board[i] & W_STONE) {
|
||||
mobilityWhite += n;
|
||||
}
|
||||
for (Square s = SQ_BEGIN; s < SQ_END; ++s) {
|
||||
if (board[s] == NO_PIECE || board[s] == BAN_STONE) {
|
||||
Square moveSquare;
|
||||
for (MoveDirection d = MD_BEGIN; d < MD_NB; ++d) {
|
||||
moveSquare = static_cast<Square>(MoveList<LEGAL>::adjacentSquares[s][d]);
|
||||
if (moveSquare) {
|
||||
if (board[moveSquare] & B_STONE) {
|
||||
mobilityBlack++;
|
||||
}
|
||||
if (board[moveSquare] & W_STONE) {
|
||||
mobilityWhite++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
diff = mobilityBlack - mobilityWhite;
|
||||
|
||||
return diff;
|
||||
return mobilityBlack - mobilityWhite;
|
||||
}
|
||||
|
||||
void Position::remove_ban_stones()
|
||||
|
@ -1236,30 +1239,6 @@ bool Position::is_all_in_mills(Color c)
|
|||
return true;
|
||||
}
|
||||
|
||||
// Stat include ban
|
||||
int Position::surrounded_empty_squares_count(Square s, bool includeBanned)
|
||||
{
|
||||
//assert(rule.hasBannedLocations == includeBanned);
|
||||
|
||||
int n = 0;
|
||||
|
||||
if (pieceOnBoardCount[sideToMove] > rule.piecesAtLeastCount ||
|
||||
!rule.mayFly) {
|
||||
Square moveSquare;
|
||||
for (MoveDirection d = MD_BEGIN; d < MD_NB; ++d) {
|
||||
moveSquare = static_cast<Square>(MoveList<LEGAL>::adjacentSquares[s][d]);
|
||||
if (moveSquare) {
|
||||
if (board[moveSquare] == 0x00 ||
|
||||
(includeBanned && board[moveSquare] == BAN_STONE)) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
void Position::surrounded_pieces_count(Square s, int &ourPieceCount, int &theirPieceCount, int &bannedCount, int &emptyCount)
|
||||
{
|
||||
Square moveSquare;
|
||||
|
|
|
@ -105,7 +105,7 @@ public:
|
|||
enum Action get_action() const;
|
||||
const char *get_record() const;
|
||||
|
||||
int get_mobility_diff(bool includeBanned);
|
||||
int get_mobility_diff();
|
||||
|
||||
bool reset();
|
||||
bool start();
|
||||
|
@ -133,7 +133,6 @@ public:
|
|||
int potential_mills_count(Square to, Color c, Square from = SQ_0);
|
||||
bool is_all_in_mills(Color c);
|
||||
|
||||
int surrounded_empty_squares_count(Square s, bool includeBanned);
|
||||
void surrounded_pieces_count(Square s, int &nOurPieces, int &nTheirPieces, int &nBanned, int &nEmpty);
|
||||
bool is_all_surrounded(Color c, Square from = SQ_0, Square to = SQ_0) const;
|
||||
|
||||
|
|
Loading…
Reference in New Issue