Skip to content

Commit

Permalink
Introduce variant piece values
Browse files Browse the repository at this point in the history
  • Loading branch information
ianfab committed Dec 29, 2020
1 parent 253f1d8 commit 839509d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/movepick.cpp
Expand Up @@ -104,7 +104,7 @@ void MovePicker::score() {

for (auto& m : *this)
if (Type == CAPTURES)
m.value = int(PieceValue[MG][pos.piece_on(to_sq(m))]) * 6
m.value = int(VariantPieceValue[MG][pos.piece_on(to_sq(m))]) * 6
+ (*captureHistory)[pos.moved_piece(m)][to_sq(m)][type_of(pos.piece_on(to_sq(m)))];

else if (Type == QUIETS)
Expand All @@ -118,7 +118,7 @@ void MovePicker::score() {
else // Type == EVASIONS
{
if (pos.capture(m))
m.value = PieceValue[MG][pos.piece_on(to_sq(m))]
m.value = VariantPieceValue[MG][pos.piece_on(to_sq(m))]
- Value(type_of(pos.moved_piece(m)));
else
m.value = (*mainHistory)[pos.side_to_move()][from_to(m)]
Expand Down
5 changes: 5 additions & 0 deletions src/psqt.cpp
Expand Up @@ -25,6 +25,8 @@
#include "variant.h"
#include "misc.h"

Value VariantPieceValue[PHASE_NB][PIECE_NB];

namespace PSQT {

#define S(mg, eg) make_score(mg, eg)
Expand Down Expand Up @@ -177,6 +179,9 @@ void init(const Variant* v) {
&& v->extinctionPieceTypes.find(ALL_PIECES) != v->extinctionPieceTypes.end())
score = -make_score(mg_value(score) / 8, eg_value(score) / 8 / (1 + !pi->sliderCapture.size()));

VariantPieceValue[MG][pc] = VariantPieceValue[MG][~pc] = mg_value(score);
VariantPieceValue[EG][pc] = VariantPieceValue[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 VariantPieceValue[PHASE_NB][PIECE_NB];


typedef int Depth;

enum : int {
Expand Down

0 comments on commit 839509d

Please sign in to comment.