Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions pleco_engine/src/root_moves/root_moves_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,15 @@ impl RootMoveList {

#[inline]
pub fn insert_score_depth(&mut self, index: usize, score: i32, depth: i16) {
unsafe {
let rm: &mut RootMove = self.get_unchecked_mut(index);
rm.score = score;
rm.depth_reached = depth;
}
let rm: &mut RootMove = &mut self[index];
rm.score = score;
rm.depth_reached = depth;
}

#[inline]
pub fn insert_score(&mut self, index: usize, score: i32) {
unsafe {
let rm: &mut RootMove = self.get_unchecked_mut(index);
rm.score = score;
}
let rm: &mut RootMove = &mut self[index];
rm.score = score;
}

pub fn find(&mut self, mov: BitMove) -> Option<&mut RootMove> {
Expand Down Expand Up @@ -196,3 +192,22 @@ impl<'a> IntoIterator for &'a RootMoveList {
impl<'a> ExactSizeIterator for MoveIter<'a> {}

impl<'a> FusedIterator for MoveIter<'a> {}

#[cfg(test)]
mod tests {
use super::*;

#[test]
#[should_panic]
fn insert_score_depth_out_of_bounds() {
let mut list = RootMoveList::new();
list.insert_score_depth(1000, 100, 10);
}

#[test]
#[should_panic]
fn insert_score_out_of_bounds() {
let mut list = RootMoveList::new();
list.insert_score(1000, 100);
}
}