From 839b4740af77743c7141e113eb7f110b4f6a9983 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 1 Aug 2026 08:14:20 +0200 Subject: optimalization and naming changes --- src/evaluate.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/evaluate.cpp') diff --git a/src/evaluate.cpp b/src/evaluate.cpp index a777e0c..3e4f72f 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -1,7 +1,9 @@ #include "evaluate.hpp" #include "board/board.hpp" #include "moves.hpp" +#include #include +#include constexpr int PAWN_VALUE = 100; constexpr int KNIGHT_VALUE = 320; @@ -105,10 +107,18 @@ static int ForceKingToEdgeBonus(const Position enemyKing, int CountBoardMaterial(Game *g) { int score = 0; - for (int i = 0; i < 64; i++) { + uint64_t piece_bitboard = g->PieceBitboard; + while (piece_bitboard != 0) { + int i = __builtin_ctzll(piece_bitboard); + piece_bitboard &= piece_bitboard - 1; + const Piece piece = g->pieces[i]; - if (piece.type == NONEPIECE) - continue; + + if (piece.type == NONEPIECE) { + assert(false && "in piece bitboard found none piece"); + std::cout << "Internal error\n"; + exit(1); + } int value = 0; -- cgit v1.2.3