general code improvements
This commit is contained in:
12
src/board.rs
12
src/board.rs
@@ -68,12 +68,10 @@ impl Board {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn possible_moves(&self, color: Piece) -> Box<dyn Iterator<Item = (usize, usize)> + '_> {
|
||||
Box::new(
|
||||
(0..BOARD_SIZE)
|
||||
.flat_map(|i| (0..BOARD_SIZE).map(move |j| (i, j)))
|
||||
.filter(move |(i, j)| self.would_prop(*i, *j, color)),
|
||||
)
|
||||
pub fn possible_moves(&self, color: Piece) -> impl Iterator<Item = (usize, usize)> + use<'_> {
|
||||
(0..BOARD_SIZE)
|
||||
.flat_map(|i| (0..BOARD_SIZE).map(move |j| (i, j)))
|
||||
.filter(move |(i, j)| self.would_prop(*i, *j, color))
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to a place on the [`Board`]
|
||||
@@ -137,8 +135,8 @@ impl Board {
|
||||
/// DO NOT USE THIS ALONE, this should be called as a part of
|
||||
/// [`Board::place`] or [`Board::place_and_prop_unchecked`]
|
||||
// TODO! this function is responsible for approx 64% of the time spent computing moves in `ComplexAgent`
|
||||
// IDEAS: early-exit from each chain so we don't have to call `diag` (which allocs a lot and uses a lot of cycles)
|
||||
// NOTE! got it down to 24.86% (61.1% decrease) with allocator optimizations
|
||||
// IDEAS: early-exit from each chain so we don't have to call `diag` (which allocs a lot and uses a lot of cycles)
|
||||
fn propegate_from_dry(&self, i: usize, j: usize, starting_color: Piece) -> Vec<(usize, usize)> {
|
||||
// Create all chains from the piece being propegated from in `i` and `j` coordinates
|
||||
let (i_chain, j_chain) = (
|
||||
|
||||
Reference in New Issue
Block a user