This commit is contained in:
2025-01-28 15:48:44 -05:00
parent aab639c04d
commit 2189f00cb3
4 changed files with 39 additions and 19 deletions

View File

@@ -15,17 +15,12 @@ impl Agent for ComplexAgent {
fn next_move(&mut self, board: &Board) -> Option<(usize, usize)> {
(0..BOARD_SIZE)
.zip(0..BOARD_SIZE)
.filter(|&(i, j)| board.get(i, j) == &Some(!self.color))
.flat_map(|(i, j)| offsets(i, j, 1))
.filter(|&(i, j)| i < BOARD_SIZE && j < BOARD_SIZE)
.filter(|&(i, j)| board.get(i, j).is_none())
.filter(|&(i, j)| board.test_prop(i, j, self.color))
// .filter(|&(i, j)| board.get(i, j) == &Some(!self.color))
// .flat_map(|(i, j)| offsets(i, j, 1))
// .filter(|&(i, j)| i < BOARD_SIZE && j < BOARD_SIZE)
// .filter(|&(i, j)| board.get(i, j).is_none())
.choose(&mut self.rng)
.or_else(|| {
(0..BOARD_SIZE)
.zip(0..BOARD_SIZE)
.filter(|&(i, j)| board.get(i, j).is_none())
.choose(&mut self.rng)
})
}
fn name(&self) -> &'static str {