printing PV and score | bench 4118297
This commit is contained in:
1 parent
674e769783
commit
6d6fababdb
4 files changed
+43
-3
No files matched your search
@@ -56,7 +56,6 @@ public:
|
||||
|
||||
void PrintMove() {
|
||||
std::cout << squareCoords[MoveFrom()] << squareCoords[MoveTo()];
|
||||
std::cout << " (" << moveTypes[GetFlags()] << ")\n";
|
||||
}
|
||||
|
||||
operator uint16_t() {
|
||||
|
||||
+10
-1
@@ -17,6 +17,8 @@ static inline bool doingNullMove = false;
|
||||
// [id][ply]
|
||||
static inline int killerMoves[2][64];
|
||||
|
||||
inline PVLine pvLine;
|
||||
|
||||
static int ScoreMove(Board &board, Move &move) {
|
||||
const int attackerType = board.GetPieceType(move.MoveFrom());
|
||||
const int targetType = board.GetPieceType(move.MoveTo());
|
||||
@@ -145,6 +147,8 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
|
||||
}
|
||||
}
|
||||
|
||||
pvLine.SetLength(ply);
|
||||
|
||||
// if NOT PV node then we try to hit the TTable
|
||||
if (beta - alpha == 1) {
|
||||
SearchResults entry = ReadEntry(board.hashKey, depth, alpha, beta);
|
||||
@@ -242,6 +246,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
|
||||
nodeType = PV;
|
||||
alpha = score;
|
||||
results.bestMove = board.moveList[i];
|
||||
pvLine.SetMove(ply, board.moveList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,7 +305,11 @@ static SearchResults ID(Board &board, SearchParams params) {
|
||||
|
||||
std::cout << "info ";
|
||||
std::cout << "depth " << depth;
|
||||
std::cout << " nodes " << nodes << " nps " << int(nodes/elapsed) << std::endl;
|
||||
std::cout << " score cp " << safeResults.score;
|
||||
std::cout << " nodes " << nodes << " nps " << int(nodes/elapsed);
|
||||
std::cout << " pv ";
|
||||
pvLine.Print(0);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
return safeResults;
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#pragma once
|
||||
#include "board.h"
|
||||
#include "uci.h"
|
||||
#include <vector>
|
||||
#include "move.h"
|
||||
|
||||
constexpr int maxDepth = 64;
|
||||
|
||||
extern U64 nodes;
|
||||
extern bool benchStarted;
|
||||
@@ -25,6 +29,33 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class PVLine {
|
||||
private:
|
||||
int length[maxDepth] = {};
|
||||
Move table[maxDepth][maxDepth] = {};
|
||||
public:
|
||||
void SetLength(int ply) {
|
||||
length[ply] = ply;
|
||||
}
|
||||
|
||||
void SetMove(int ply, Move move) {
|
||||
table[ply][ply] = move;
|
||||
|
||||
for (int i = ply + 1; i < length[ply + 1]; i++) {
|
||||
table[ply][i] = table[ply+1][i];
|
||||
}
|
||||
|
||||
length[ply] = length[ply + 1];
|
||||
}
|
||||
|
||||
void Print(int n) {
|
||||
for (int i = 0; i < length[n]; i++) {
|
||||
table[n][i].PrintMove();
|
||||
std::cout << ' ';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SearchResults PVS(Board board, int depth, int alpha, int beta);
|
||||
void SearchPosition(Board &board, SearchParams params);
|
||||
void StopSearch();
|
||||
|
||||
+2
-1
@@ -207,7 +207,8 @@ void UCILoop(Board &board) {
|
||||
|
||||
// parse UCI "ucinewgame" command
|
||||
if (input.find("ucinewgame") != std::string::npos) {
|
||||
ParsePosition(board, "position startpos");
|
||||
board.SetByFen(StartingFen);
|
||||
TTable.clear();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user