Skip to content

Commit

Permalink
Introduce variant piece values
Browse files Browse the repository at this point in the history
For future improvements.

No functional change.
  • Loading branch information
ianfab committed Jan 4, 2021
1 parent 34a0823 commit f4864ec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/psqt.cpp
Expand Up @@ -25,6 +25,9 @@
#include "variant.h"
#include "misc.h"

Value EvalPieceValue[PHASE_NB][PIECE_NB];
Value CapturePieceValue[PHASE_NB][PIECE_NB];

namespace PSQT {

#define S(mg, eg) make_score(mg, eg)
Expand Down Expand Up @@ -157,8 +160,8 @@ void init(const Variant* v) {

// For drop variants, halve the piece values
if (v->capturesToHand)
score = make_score(mg_value(score) * 3500 / (7000 + mg_value(score)),
eg_value(score) * 3500 / (7000 + eg_value(score)));
score = make_score(mg_value(score) * 7000 / (7000 + mg_value(score)),
eg_value(score) * 7000 / (7000 + eg_value(score)));
else if (!v->checking)
score = make_score(mg_value(score) * 2000 / (3500 + mg_value(score)),
eg_value(score) * 2200 / (3500 + eg_value(score)));
Expand All @@ -176,10 +179,19 @@ void init(const Variant* v) {
score += make_score(std::max(QueenValueMg - PieceValue[MG][pt], VALUE_ZERO) / 20,
std::max(QueenValueEg - PieceValue[EG][pt], VALUE_ZERO) / 20);

CapturePieceValue[MG][pc] = CapturePieceValue[MG][~pc] = mg_value(score);
CapturePieceValue[EG][pc] = CapturePieceValue[EG][~pc] = eg_value(score);

// For antichess variants, use negative piece values
if (v->extinctionValue == VALUE_MATE)
score = -make_score(mg_value(score) / 8, eg_value(score) / 8 / (1 + !pi->sliderCapture.size()));

if (v->capturesToHand)
score = score / 2;

EvalPieceValue[MG][pc] = EvalPieceValue[MG][~pc] = mg_value(score);
EvalPieceValue[EG][pc] = EvalPieceValue[EG][~pc] = eg_value(score);

// Determine pawn rank
std::istringstream ss(v->startFen);
unsigned char token;
Expand Down
3 changes: 3 additions & 0 deletions src/types.h
Expand Up @@ -470,6 +470,9 @@ constexpr Value PieceValue[PHASE_NB][PIECE_NB] = {
static_assert( PieceValue[MG][PIECE_TYPE_NB + 1] == PawnValueMg
&& PieceValue[EG][PIECE_TYPE_NB + 1] == PawnValueEg, "PieceValue array broken");

extern Value EvalPieceValue[PHASE_NB][PIECE_NB]; // variant piece values for evaluation
extern Value CapturePieceValue[PHASE_NB][PIECE_NB]; // variant piece values for captures/search

typedef int Depth;

enum : int {
Expand Down

0 comments on commit f4864ec

Please sign in to comment.