Skip to content

Commit

Permalink
Fixed PV and move parsing for UCI display bugs. Reorganized some sect…
Browse files Browse the repository at this point in the history
…ions of code
  • Loading branch information
DkeRee committed May 4, 2022
1 parent 6709031 commit 6093b79
Show file tree
Hide file tree
Showing 7 changed files with 285 additions and 205 deletions.
26 changes: 16 additions & 10 deletions src/eval/eval_info.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
#![allow(dead_code)]
#![allow(non_upper_case_globals)]

pub const square_display: [&str; 64] = [
"a1", "b1", "c1", "d1", "e1", "f1", "g1", "h1",
"a2", "b2", "c2", "d2", "e2", "f2", "g2", "h2",
"a3", "b3", "c3", "d3", "e3", "f3", "g3", "h3",
"a4", "b4", "c4", "d4", "e4", "f4", "g4", "h4",
"a5", "b5", "c5", "d5", "e5", "f5", "g5", "h5",
"a6", "b6", "c6", "d6", "e6", "f6", "g6", "h6",
"a7", "b7", "c7", "d7", "e7", "f7", "g7", "h7",
"a8", "b8", "c8", "d8", "e8", "f8", "g8", "h8"
];
//PIECE WEIGHTS
pub const pawn_normal: i32 = 126;
pub const pawn_endgame: i32 = 208;

pub const knight_normal: i32 = 781;
pub const knight_endgame: i32 = 854;

pub const bishop_normal: i32 = 825;
pub const bishop_endgame: i32 = 915;

pub const rook_normal: i32 = 1276;
pub const rook_endgame: i32 = 1380;

pub const queen_normal: i32 = 2538;
pub const queen_endgame: i32 = 2682;

//now replaced with see swap algorithm
pub const MVV_LVA: [u32; 49] = [
0, 0, 0, 0, 0, 0, 0, // victim K, attacker K, Q, R, B, N, P, None
50, 51, 52, 53, 54, 55, 0, // victim Q, attacker K, Q, R, B, N, P, None
Expand Down
40 changes: 20 additions & 20 deletions src/eval/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ impl Evaluator {
Piece::Pawn => {
let mut weight = 0;
if self.end_game {
weight = 208;
weight = pawn_endgame;
} else {
weight = 126;
weight = pawn_normal;
}

piece_sum = weight;
Expand All @@ -52,9 +52,9 @@ impl Evaluator {
Piece::Knight => {
let mut weight = 0;
if self.end_game {
weight = 854;
weight = knight_endgame;
} else {
weight = 781;
weight = knight_normal;
}

piece_sum = weight;
Expand All @@ -68,9 +68,9 @@ impl Evaluator {
Piece::Bishop => {
let mut weight = 0;
if self.end_game {
weight = 915;
weight = bishop_endgame;
} else {
weight = 825;
weight = bishop_normal;
}

piece_sum = weight;
Expand All @@ -84,9 +84,9 @@ impl Evaluator {
Piece::Rook => {
let mut weight = 0;
if self.end_game {
weight = 1380;
weight = rook_endgame;
} else {
weight = 1276;
weight = rook_normal;
}

piece_sum = weight;
Expand All @@ -100,9 +100,9 @@ impl Evaluator {
Piece::Queen => {
let mut weight = 0;
if self.end_game {
weight = 2682;
weight = queen_endgame;
} else {
weight = 2538;
weight = queen_normal;
}

piece_sum = weight;
Expand Down Expand Up @@ -143,9 +143,9 @@ impl Evaluator {
Piece::Pawn => {
let mut weight = 0;
if self.end_game {
weight = 208;
weight = pawn_endgame;
} else {
weight = 126;
weight = pawn_normal;
}

piece_sum = weight;
Expand All @@ -159,9 +159,9 @@ impl Evaluator {
Piece::Knight => {
let mut weight = 0;
if self.end_game {
weight = 854;
weight = knight_endgame;
} else {
weight = 781;
weight = knight_normal;
}

piece_sum = weight;
Expand All @@ -175,9 +175,9 @@ impl Evaluator {
Piece::Bishop => {
let mut weight = 0;
if self.end_game {
weight = 915;
weight = bishop_endgame;
} else {
weight = 825;
weight = bishop_normal;
}

piece_sum = weight;
Expand All @@ -191,9 +191,9 @@ impl Evaluator {
Piece::Rook => {
let mut weight = 0;
if self.end_game {
weight = 1380;
weight = rook_endgame;
} else {
weight = 1276;
weight = rook_normal;
}

piece_sum = weight;
Expand All @@ -207,9 +207,9 @@ impl Evaluator {
Piece::Queen => {
let mut weight = 0;
if self.end_game {
weight = 2682;
weight = queen_endgame;
} else {
weight = 2538;
weight = queen_normal;
}

piece_sum = weight;
Expand Down
17 changes: 17 additions & 0 deletions src/movegen/movegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ pub struct SortedMove {
pub movetype: MoveType
}

#[derive(Clone, Debug, PartialEq)]
pub struct Eval {
pub score: i32,
pub mate: bool,
pub mate_ply: usize
}

//mvv_lva MVV_LVA[(self.piece_index(moves.piece) * 7) + self.piece_index(piece)]

impl SortedMove {
Expand All @@ -20,6 +27,16 @@ impl SortedMove {
}
}

impl Eval {
pub fn new(score: i32, mate: bool, mate_ply: usize) -> Eval {
Eval {
score: score,
mate: mate,
mate_ply: mate_ply
}
}
}

pub struct MoveGen {
sorter: MoveSorter
}
Expand Down
Loading

0 comments on commit 6093b79

Please sign in to comment.