diff --git a/source/evaluate.cpp b/source/evaluate.cpp new file mode 100644 index 0000000..dec8472 --- /dev/null +++ b/source/evaluate.cpp @@ -0,0 +1,16 @@ +#include "evaluate.h" + +int Evaluate(Board &board) { + int score = 0; + + for (int color = White; color <= Black; color++) { + for (int type = Pawn; type <= King; type++) { + int side = color ? -1 : 1; + + score += (board.pieces[type] & board.colors[color]).PopCount() + * materialValues[type] * side; + } + } + + return score; +} \ No newline at end of file diff --git a/source/evaluate.h b/source/evaluate.h new file mode 100644 index 0000000..a2a4936 --- /dev/null +++ b/source/evaluate.h @@ -0,0 +1,13 @@ +#pragma once +#include "board.h" + +constexpr int materialValues[] { + 100, // Pawn + 300, // Knight + 350, // Bishop + 500, // Rook + 1000, // Queen + 10000 // King +}; + +int Evaluate(Board &board); \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index c481de2..c3c0107 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -3,14 +3,15 @@ #include "board.h" #include "movegen.h" #include "perft.h" +#include "evaluate.h" int main() { initLeaperAttacks(); initSliderAttacks(); - Board board; - board.SetByFen("rnbq1k1r/pp1Pbppp/2p5/8/2B5/8/PPP1NnPP/RNBQK2R w KQ - 1 8"); - Perft(board, 6); + Board board; + + std::cout << Evaluate(board) << '\n'; return 0; } \ No newline at end of file