Skip to content

Commit a91eddd

Browse files
committed
some rewrites
1 parent 2cd15d4 commit a91eddd

File tree

9 files changed

+1060
-1479
lines changed

9 files changed

+1060
-1479
lines changed

eval.cpp

Lines changed: 635 additions & 1099 deletions
Large diffs are not rendered by default.

eval.h

Lines changed: 3 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <vector>
55
#include <cstdint>
66
#include <cstring>
7-
#include "tt.hpp"
87
#if __cplusplus >= 202002L
98
#define POPCOUNT64(bits) std::popcount(bits);
109
#elif defined(USE_POPCNT)
@@ -214,102 +213,10 @@ namespace chess
214213
MoveStack move_stack;
215214
};
216215
};
217-
218-
using U64 = uint64_t;
219-
220-
// Constants for board files
221-
constexpr U64 FILE_A = 0x0101010101010101ULL, RANK_1 = 0xff;
222-
constexpr U64 FILE_B = FILE_A << 1, RANK_2 = RANK_1 << 8;
223-
constexpr U64 FILE_C = FILE_A << 2, RANK_3 = RANK_2 << 8;
224-
constexpr U64 FILE_D = FILE_A << 3, RANK_4 = RANK_3 << 8;
225-
constexpr U64 FILE_E = FILE_A << 4, RANK_5 = RANK_4 << 8;
226-
constexpr U64 FILE_F = FILE_A << 5, RANK_6 = RANK_5 << 8;
227-
constexpr U64 FILE_G = FILE_A << 6, RANK_7 = RANK_6 << 8;
228-
constexpr U64 FILE_H = FILE_A << 7, RANK_8 = RANK_7 << 8;
229-
230-
constexpr U64 FILES[8] = {FILE_A, FILE_B, FILE_C, FILE_D, FILE_E, FILE_F, FILE_G, FILE_H};
231-
typedef unsigned long long Bitboard;
232-
typedef char Square;
233-
234-
// Shift functions for pawn movement
235-
inline U64 north(U64 b) { return b << 8; }
236-
inline U64 south(U64 b) { return b >> 8; }
237-
inline U64 east(U64 b) { return (b & ~FILE_H) << 1; }
238-
inline U64 west(U64 b) { return (b & ~FILE_A) >> 1; }
239-
inline U64 northEast(U64 b) { return (b & ~FILE_H) << 9; }
240-
inline U64 northWest(U64 b) { return (b & ~FILE_A) << 7; }
241-
inline U64 southEast(U64 b) { return (b & ~FILE_H) >> 7; }
242-
inline U64 southWest(U64 b) { return (b & ~FILE_A) >> 9; }
243-
#define getQueenAttacks(a, b) chess::attacks::queen(a, b).getBits()
244-
#define getKnightAttacks(a, ...) chess::attacks::knight(a).getBits()
245-
#define getKingAttacks(a, friendlyPieces) (chess::attacks::king(a).getBits() & ~(friendlyPieces))
246-
#define getRookAttacks(a, b) chess::attacks::rook(a, b).getBits()
247-
#define getBishopAttacks(a, b) chess::attacks::bishop(a, b).getBits()
248-
#define getPawnAttacks(a, b) chess::attacks::pawn(a, b).getBits()
249216
#define MAX_PLY 245
250-
#define MAX 32767 // for black
251217
#define MAX_MATE 31999
218+
#define MAX_SCORE_CP 31000
252219
#define MATE(i) MAX_MATE-i
253220
#define MATE_DISTANCE(i) (i - MAX_MATE)
254-
int eval(chess::Position &RESTRICT board);
255-
int piece_value(chess::PieceType piece);
256-
// Define enum class for evaluation keys
257-
enum class EvalKey
258-
{
259-
DOUBLED,
260-
BACKWARD,
261-
BLOCKED,
262-
ISLANDED,
263-
ISOLATED,
264-
DBLISOLATED,
265-
WEAK,
266-
PAWNRACE,
267-
SHIELD,
268-
STORM,
269-
OUTPOST,
270-
LEVER,
271-
PAWNRAM,
272-
OPENPAWN,
273-
HOLES,
274-
UNDEV_KNIGHT,
275-
UNDEV_BISHOP,
276-
UNDEV_ROOK,
277-
DEV_QUEEN,
278-
OPEN_FILES,
279-
SEMI_OPEN_FILES,
280-
FIANCHETTO,
281-
TRAPPED,
282-
KEY_CENTER,
283-
SPACE,
284-
BADBISHOP,
285-
WEAKCOVER,
286-
MISSINGPAWN,
287-
ATTACK_ENEMY,
288-
K_OPENING,
289-
K_MIDDLE,
290-
K_END,
291-
PINNED,
292-
SKEWERED,
293-
DISCOVERED,
294-
FORK,
295-
TEMPO_FREEDOM_WEIGHT,
296-
TEMPO_OPPONENT_MOBILITY_PENALTY,
297-
UNDERPROMOTE,
298-
PAWN,
299-
KNIGHT,
300-
BISHOP,
301-
ROOK,
302-
QUEEN,
303-
COUNTER
304-
};
305-
// Struct to hold evaluation weights
306-
struct EvalWeights
307-
{
308-
static const std::unordered_map<EvalKey, int> weights;
309-
310-
static int getWeight(EvalKey key)
311-
{
312-
auto it = weights.find(key);
313-
return (it != weights.end()) ? it->second : 0; // Default if key not found
314-
}
315-
};
221+
int eval(chess::Position &board);
222+
constexpr int16_t ASPIRATION_DELTA = 30;

0 commit comments

Comments
 (0)