Chess-Plisco
view release on metacpan or search on metacpan
lib/Chess/Plisco/Engine/Position.pm view on Meta::CPAN
#! /bin/false
# Copyright (C) 2021-2026 Guido Flohr <guido.flohr@cantanea.com>,
# all rights reserved.
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What the Fuck You Want
# to Public License, Version 2, as published by Sam Hocevar. See
# http://www.wtfpl.net/ for more details.
package Chess::Plisco::Engine::Position;
$Chess::Plisco::Engine::Position::VERSION = 'v1.0.3';
use strict;
use integer;
use Chess::Plisco qw(:all);
# Macros from Chess::Plisco::Macro are already expanded here!
use base qw(Chess::Plisco Exporter);
# Additional fields.
use constant CP_POS_SIGNATURE => CP_POS_USR1;
use constant CP_POS_REVERSIBLE_CLOCK => CP_POS_USR2;
use constant CP_POS_GAME_PHASE => CP_POS_USR3;
use constant CP_POS_OPENING_SCORE => CP_POS_USR4;
use constant CP_POS_ENDGAME_SCORE => CP_POS_USR5;
use constant CP_POS_POPCOUNT => CP_POS_USR6;
our @EXPORT_OK = qw(CP_POS_REVERSIBLE_CLOCK CP_POS_POPCOUNT);
use constant PAWN_PHASE => 0;
use constant KNIGHT_PHASE => 1;
use constant BISHOP_PHASE => 1;
use constant ROOK_PHASE => 2;
use constant QUEEN_PHASE => 4;
use constant TOTAL_PHASE => PAWN_PHASE * 16
+ KNIGHT_PHASE * 4 + BISHOP_PHASE * 4
+ ROOK_PHASE * 4 + QUEEN_PHASE * 2;
use constant PHASE_INC => [
0,
PAWN_PHASE,
KNIGHT_PHASE,
BISHOP_PHASE,
ROOK_PHASE,
QUEEN_PHASE,
0,
];
my @op_value = (0, 82, 337, 365, 477, 1025, 0);
my @eg_value = (0, 94, 281, 297, 512, 936, 0);
# piece/sq tables
# values from Rofchade: http://www.talkchess.com/forum3/viewtopic.php?f=2&t=68311&start=19
my @op_pawn_table = (
0, 0, 0, 0, 0, 0, 0, 0,
98, 134, 61, 95, 68, 126, 34, -11,
-6, 7, 26, 31, 65, 56, 25, -20,
-14, 13, 6, 21, 23, 12, 17, -23,
-27, -2, -5, 12, 17, 6, 10, -25,
-26, -4, -4, -10, 3, 3, 33, -12,
# 47, 81, 62, 59, 67, 106, 120, 60
-35, -1, -20, -23, -15, 24, 38, -22,
0, 0, 0, 0, 0, 0, 0, 0,
);
my @eg_pawn_table = (
0, 0, 0, 0, 0, 0, 0, 0,
178, 173, 158, 134, 147, 132, 165, 187,
94, 100, 85, 67, 56, 53, 82, 84,
32, 24, 13, 5, -2, 4, 17, 17,
13, 9, -3, -7, -7, -8, 3, -1,
4, 7, -6, 1, 0, -5, -1, -8,
13, 8, 8, 10, 13, 0, 2, -7,
0, 0, 0, 0, 0, 0, 0, 0,
);
( run in 0.956 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )