add comments

This commit is contained in:
Simon Gardling 2025-01-28 16:20:01 -05:00
parent 652ea97f83
commit db627f087f
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D
2 changed files with 2 additions and 25 deletions

View File

@ -17,9 +17,9 @@ impl Agent for ComplexAgent {
.collect::<Vec<(usize, usize)>>() .collect::<Vec<(usize, usize)>>()
}) })
.map(|(i, j)| (i, j, board.move_would_propegate(i, j, self.color))) .map(|(i, j)| (i, j, board.move_would_propegate(i, j, self.color)))
.filter(|&(_, _, c)| c >= 0) .filter(|&(_, _, c)| c >= 0) // a `c` value of less than 0 implies the move is invalid: TODO! make this an enum or smth
.max_by_key(|&(_, _, c)| c) .max_by_key(|&(_, _, c)| c)
.map(|(i, j, _)| (i, j)) .map(|(i, j, _)| (i, j)) // remove `c` and return the best move
} }
fn name(&self) -> &'static str { fn name(&self) -> &'static str {

View File

@ -22,29 +22,6 @@ where
output output
} }
pub fn offsets(i: usize, j: usize, range: usize) -> Vec<(usize, usize)> {
let mut output = Vec::new();
for i_o in [-(range as i16), 0, range as i16] {
let new_i = i as i16 + i_o;
if 0 > new_i {
continue;
}
for j_o in [-(range as i16), 0, range as i16] {
if (i_o, j_o) == (0, 0) {
continue;
}
let new_j = j as i16 + j_o;
if 0 > new_j {
continue;
}
output.push((new_i as usize, new_j as usize));
}
}
output
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;