ai: enable using hold if it is initially empty

This commit is contained in:
tali 2023-04-11 13:16:56 -04:00
parent 89f64aa8d8
commit a40d336911
1 changed files with 6 additions and 1 deletions

View File

@ -205,7 +205,12 @@ struct Queue {
}
impl Queue {
fn alloc(arena: &Bump, previews: &[PieceType], hold: Option<PieceType>) -> Self {
fn alloc(arena: &Bump, mut previews: &[PieceType], mut hold: Option<PieceType>) -> Self {
if hold.is_none() && !previews.is_empty() {
hold = Some(previews[0]);
previews = &previews[1..];
}
Queue {
next: arena.alloc_slice_copy(previews),
held: hold,