From 968d0f53773cd2d3de8bb75a1b61d728d6416d65 Mon Sep 17 00:00:00 2001 From: rektdie Date: Thu, 20 Mar 2025 19:56:23 +0100 Subject: [PATCH] refactor in evaluate --- source/evaluate.cpp | 3 +++ source/evaluate.h | 5 ++++- source/search.cpp | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/source/evaluate.cpp b/source/evaluate.cpp index 6c7cb31..37ab761 100644 --- a/source/evaluate.cpp +++ b/source/evaluate.cpp @@ -1,5 +1,7 @@ #include "evaluate.h" +namespace HCE { + static int GetPhaseWeight(Board &board, int color) { int phase = 0; @@ -60,3 +62,4 @@ int Evaluate(Board &board) { return board.sideToMove ? -score : score; } +} \ No newline at end of file diff --git a/source/evaluate.h b/source/evaluate.h index 5bec50d..0f2514c 100644 --- a/source/evaluate.h +++ b/source/evaluate.h @@ -1,6 +1,8 @@ #pragma once #include "board.h" +namespace HCE { + constexpr int phaseMax = 24; constexpr int phaseValues[4] { @@ -154,4 +156,5 @@ constexpr int scoreSquares[64] { a1, b1, c1, d1, e1, f1, g1, h1 }; -int Evaluate(Board &board); \ No newline at end of file +int Evaluate(Board &board); +} diff --git a/source/search.cpp b/source/search.cpp index 33f7db9..21085ea 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -118,7 +118,7 @@ static SearchResults Quiescence(Board board, int alpha, int beta, int ply) { } } - int bestScore = Evaluate(board); + int bestScore = HCE::Evaluate(board); if (bestScore>= beta) { return bestScore; @@ -181,7 +181,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) { if (depth <= 0) return Quiescence(board, alpha, beta, ply); - const int staticEval = Evaluate(board); + const int staticEval = HCE::Evaluate(board); if (board.InCheck(board.sideToMove)) { depth++;