fix tiles not being unclaimed after multiple marble creations block each other

This commit is contained in:
Crispy 2025-03-14 22:20:48 +01:00
parent ce2e7c252a
commit bb2b1fea7c
2 changed files with 31 additions and 2 deletions

View file

@ -255,13 +255,17 @@ impl Machine {
}
// #### new marbles ####
let mut claim_positions = Vec::new();
// prepare creating the new marbles
for &(pos, _val, _dir) in &new_marbles {
let Some(Tile::Open(OpenTile::Blank, claim)) = self.board.get_mut(pos) else {
unreachable!()
};
*claim = match claim {
Claim::Free => Claim::Claimed,
Claim::Free => {
claim_positions.push(pos);
Claim::Claimed
}
Claim::Claimed | Claim::Blocked => Claim::Blocked,
_ => unreachable!(),
}
@ -277,7 +281,6 @@ impl Machine {
}
// #### movement ####
let mut claim_positions = Vec::new();
// mark claims to figure out what spaces can be moved to
for &pos in &self.marbles[..old_marbles] {
let Some(Tile::Marble { value: _, dir }) = self.board.get(pos) else {