Skip to content

Commit

Permalink
tapered eval
Browse files Browse the repository at this point in the history
  • Loading branch information
Avo-k committed Jul 5, 2021
1 parent e896d3a commit 65e1b7c
Show file tree
Hide file tree
Showing 4 changed files with 329 additions and 157 deletions.
64 changes: 50 additions & 14 deletions constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
mate_in_2 = "k7/6R1/2K5/8/8/8/8/8 w - - 16 9"
mate_in_4 = "2k5/5R2/3K4/8/8/8/8/8 w - - 12 7"

FENS = (start_position, tricky_position, killer_position, cmk_position, repetitions_position, mate_in_2, mate_in_4)

# Mating bounds for mating scores
BOUND_INF, UPPER_MATE, LOWER_MATE = 50000, 49000, 48000

Expand All @@ -92,6 +94,9 @@
full_depth_moves = 4
reduction_limit = 3

# Time
time_precision = 2047

# Hash Constants

# init random hash keys
Expand All @@ -111,11 +116,18 @@
# Evaluation Constants

# Material values
# P N B R Q K
material_scores = ((100, 325, 335, 500, 1000, 12000),
(110, 310, 315, 550, 1050, 12000))

material_score = (100, 320, 330, 500, 950, 12000)
# P N B R Q K
phase_scores = (0, 1, 1, 2, 4, 0)
TOTAL_PHASE = 24

mg_phase_score = 6000
eg_phase_score = 500
eg_phase_score = 1000

opening, end_game, middle_game = np.arange(3, dtype=np.uint8)

pawn_pst = (
0, 0, 0, 0, 0, 0, 0, 0,
Expand All @@ -127,6 +139,16 @@
-10, -4, 0, 16, 12, 0, -4, -10,
0, 0, 0, 0, 0, 0, 0, 0)

pawn_pst_eg = (
0, 0, 0, 0, 0, 0, 0, 0,
-5, -2, 0, 0, 0, 0, -2, -5,
-5, -2, 0, 3, 3, 0, -2, -5,
-5, -2, 1, 7, 7, 1, -2, -5,
-5, -2, 1, 7, 7, 1, -2, -5,
-5, -2, 1, 7, 7, 1, -2, -5,
-5, -2, 1, 7, 7, 1, -2, -5,
0, 0, 0, 0, 0, 0, 0, -5)

knight_pst = (
-20, 0, -10, -10, -10, -10, -10, -20,
-10, 0, 0, 3, 3, 0, 0, -10,
Expand Down Expand Up @@ -157,17 +179,26 @@
-5, 0, 0, 0, 0, 0, 0, -5,
0, 0, 0, 5, 5, 0, 0, 0)

king_pst = (
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 5, 5, 5, 5, 0, 0,
0, 5, 5, 10, 10, 5, 5, 0,
0, 5, 10, 20, 20, 10, 5, 0,
0, 5, 10, 20, 20, 10, 5, 0,
0, 0, 5, 10, 10, 5, 0, 0,
0, 5, 5, -5, -5, 0, 5, 0,
0, 0, 5, 0, -15, 0, 10, 0)

PST = np.array((pawn_pst, knight_pst, bishop_pst, rook_pst, np.zeros(64), king_pst), dtype=np.int8)
king_pst_eg = (-17, -14, -10, -7, -7, -10, -14, -17,
-10, -7, -4, 0, 0, -4, -7, -10,
-10, -4, 6, 10, 10, 6, -4, -10,
-10, -4, 10, 13, 13, 10, -4, -10,
-10, -4, 10, 13, 13, 10, -4, -10,
-10, -4, 6, 10, 10, 6, -4, -10,
-10, -10, 0, 0, 0, 0, -10, -10,
-17, -10, -10, -10, -10, -10, -10, -17)

king_pst = (-10, -14, -14, -17, -17, -14, -14, -10,
-10, -14, -14, -17, -17, -14, -14, -10,
-10, -14, -14, -17, -17, -14, -14, -10,
-10, -14, -14, -17, -17, -14, -14, -10,
-7, -10, -10, -14, -14, -10, -10, -7,
-4, -7, -7, -7, -7, -7, -7, -4,
6, 6, 0, 0, 0, 0, 6, 6,
6, 10, 3, 0, 0, 3, 10, 6)

PST = np.array(((pawn_pst, knight_pst, bishop_pst, rook_pst, np.zeros(64), king_pst),
(pawn_pst_eg, knight_pst, bishop_pst, rook_pst, np.zeros(64), king_pst_eg)), dtype=np.int8)

mirror_pst = (
a1, b1, c1, d1, e1, f1, g1, h1,
Expand Down Expand Up @@ -241,6 +272,11 @@
rook_tropism_mg = 2
queen_tropism_mg = 2

knight_tropism_eg = 1
bishop_tropism_eg = 1
rook_tropism_eg = 1
queen_tropism_eg = 4


@njit
def manhattan_distance(sq1, sq2):
Expand All @@ -252,4 +288,4 @@ def manhattan_distance(sq1, sq2):
arr_manhattan = np.array(
[manhattan_distance(sq1, sq2) for sq1 in range(64) for sq2 in range(64)],
dtype=np.uint8)
arr_manhattan.shape = (64, 64)
arr_manhattan.shape = (64, 64)
Loading

0 comments on commit 65e1b7c

Please sign in to comment.