History #19
+21
-11
@@ -14,6 +14,8 @@ static inline bool doingNullMove = false;
|
|||||||
|
|
||||||
// [id][ply]
|
// [id][ply]
|
||||||
static inline int killerMoves[2][64];
|
static inline int killerMoves[2][64];
|
||||||
|
// [stm][from][to]
|
||||||
|
static inline int historyMoves[2][64][64];
|
||||||
|
|
||||||
inline PVLine pvLine;
|
inline PVLine pvLine;
|
||||||
|
|
||||||
@@ -33,14 +35,15 @@ static int ScoreMove(Board &board, Move &move) {
|
|||||||
targetType = Pawn;
|
targetType = Pawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
return moveScoreTable[attackerType][targetType] + 10000;
|
return moveScoreTable[attackerType][targetType] + 30000;
|
||||||
} else {
|
} else {
|
||||||
if (killerMoves[0][ply] == move) {
|
if (killerMoves[0][ply] == move) {
|
||||||
return 9000;
|
return 20000;
|
||||||
}
|
} else if (killerMoves[1][ply] == move) {
|
||||||
|
return 18000;
|
||||||
if (killerMoves[1][ply] == move) {
|
} else {
|
||||||
return 8000;
|
// Max 16384
|
||||||
|
return historyMoves[board.sideToMove][move.MoveFrom()][move.MoveTo()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,8 +206,10 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
|
|||||||
|
|
||||||
// For all moves
|
// For all moves
|
||||||
for (int i = 0; i < board.currentMoveIndex; i++) {
|
for (int i = 0; i < board.currentMoveIndex; i++) {
|
||||||
|
Move currMove = board.moveList[i];
|
||||||
|
|
||||||
Board copy = board;
|
Board copy = board;
|
||||||
copy.MakeMove(copy.moveList[i]);
|
copy.MakeMove(currMove);
|
||||||
|
|
||||||
// First move (suspected PV node)
|
// First move (suspected PV node)
|
||||||
if (!i) {
|
if (!i) {
|
||||||
@@ -228,8 +233,13 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
|
|||||||
|
|
||||||
// Fail high (beta cutoff)
|
// Fail high (beta cutoff)
|
||||||
if (score >= beta) {
|
if (score >= beta) {
|
||||||
killerMoves[1][ply] = killerMoves[0][ply];
|
if (!currMove.IsCapture()) {
|
||||||
killerMoves[0][ply] = board.moveList[i];
|
killerMoves[1][ply] = killerMoves[0][ply];
|
||||||
|
killerMoves[0][ply] = currMove;
|
||||||
|
|
||||||
|
historyMoves[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()] =
|
||||||
|
std::min(16384, historyMoves[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()] + depth * depth);
|
||||||
|
}
|
||||||
|
|
||||||
TT.WriteEntry(board.hashKey, depth, score, CutNode, Move());
|
TT.WriteEntry(board.hashKey, depth, score, CutNode, Move());
|
||||||
return score;
|
return score;
|
||||||
@@ -240,8 +250,8 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
|
|||||||
if (score > alpha) {
|
if (score > alpha) {
|
||||||
nodeType = PV;
|
nodeType = PV;
|
||||||
alpha = score;
|
alpha = score;
|
||||||
results.bestMove = board.moveList[i];
|
results.bestMove = currMove;
|
||||||
pvLine.SetMove(ply, board.moveList[i]);
|
pvLine.SetMove(ply, currMove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user