improvements

This commit is contained in:
2025-01-28 16:09:40 -05:00
parent 2189f00cb3
commit 6ed4208534
2 changed files with 37 additions and 33 deletions

View File

@@ -14,13 +14,15 @@ pub struct ComplexAgent {
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.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)
.flat_map(|i| {
(0..BOARD_SIZE)
.map(|j| (i, j))
.collect::<Vec<(usize, usize)>>()
})
.map(|(i, j)| (i, j, board.move_would_propegate(i, j, self.color)))
.filter(|&(_, _, c)| c >= 0)
.max_by_key(|&(_, _, c)| c)
.map(|(i, j, _)| (i, j))
}
fn name(&self) -> &'static str {