iterator fixes
This commit is contained in:
11
src/agent.rs
11
src/agent.rs
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
board::{Board, BOARD_SIZE},
|
||||
board::Board,
|
||||
piece::Piece,
|
||||
};
|
||||
use rand::prelude::*;
|
||||
@@ -59,14 +59,7 @@ pub struct RandomAgent {
|
||||
|
||||
impl Agent for RandomAgent {
|
||||
fn next_move(&mut self, board: &Board) -> Option<(usize, usize)> {
|
||||
(0..BOARD_SIZE)
|
||||
.flat_map(|i| {
|
||||
(0..BOARD_SIZE)
|
||||
.map(|j| (i, j))
|
||||
.collect::<Vec<(usize, usize)>>()
|
||||
})
|
||||
.flat_map(|(i, j)| board.what_if(i, j, self.color).map(|_| (i, j)))
|
||||
.choose(&mut rand::rng())
|
||||
board.possible_moves(self.color).choose(&mut rand::rng())
|
||||
}
|
||||
|
||||
fn name(&self) -> &'static str {
|
||||
|
||||
Reference in New Issue
Block a user