perf: borrow in the evalscore piece changes
This commit is contained in:
parent
4b245e0421
commit
1c4c158053
12
src/eval.rs
12
src/eval.rs
@ -52,14 +52,14 @@ pub(crate) mod eval_score {
|
||||
/// Add/remove the value of a piece based on the PST.
|
||||
///
|
||||
/// Use +1 as sign to add, -1 to delete.
|
||||
fn change_piece(&mut self, pc: ColPiece, sq: Square, sign: i8) {
|
||||
fn change_piece(&mut self, pc: &ColPiece, sq: &Square, sign: i8) {
|
||||
assert!(sign == 1 || sign == -1);
|
||||
let tables = [
|
||||
(&mut self.midgame, PST_MIDGAME),
|
||||
(&mut self.endgame, PST_ENDGAME),
|
||||
(&mut self.midgame, &PST_MIDGAME),
|
||||
(&mut self.endgame, &PST_ENDGAME),
|
||||
];
|
||||
for (phase, pst) in tables {
|
||||
phase.score += pst[pc.pc][pc.col][sq] * EvalInt::from(pc.col.sign() * sign);
|
||||
phase.score += pst[pc.pc][pc.col][*sq] * EvalInt::from(pc.col.sign() * sign);
|
||||
}
|
||||
|
||||
use crate::Piece::*;
|
||||
@ -73,12 +73,12 @@ pub(crate) mod eval_score {
|
||||
}
|
||||
|
||||
/// Remove the value of a piece on a square.
|
||||
pub fn del_piece(&mut self, pc: ColPiece, sq: Square) {
|
||||
pub fn del_piece(&mut self, pc: &ColPiece, sq: &Square) {
|
||||
self.change_piece(pc, sq, -1);
|
||||
}
|
||||
|
||||
/// Add the value of a piece on a square.
|
||||
pub fn add_piece(&mut self, pc: ColPiece, sq: Square) {
|
||||
pub fn add_piece(&mut self, pc: &ColPiece, sq: &Square) {
|
||||
self.change_piece(pc, sq, 1);
|
||||
}
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ impl Board {
|
||||
let pl = &mut self[pc.col];
|
||||
pl[pc.into()].on_sq(sq);
|
||||
*self.mail.sq_mut(sq) = Some(pc);
|
||||
self.eval.add_piece(pc, sq);
|
||||
self.eval.add_piece(&pc, &sq);
|
||||
dest_pc
|
||||
}
|
||||
|
||||
@ -487,7 +487,7 @@ impl Board {
|
||||
let pl = &mut self[pc.col];
|
||||
pl[pc.into()].off_sq(sq);
|
||||
*self.mail.sq_mut(sq) = None;
|
||||
self.eval.del_piece(pc, sq);
|
||||
self.eval.del_piece(&pc, &sq);
|
||||
Some(pc)
|
||||
} else {
|
||||
None
|
||||
|
Loading…
Reference in New Issue
Block a user