Skip to content

Commit

Permalink
Add BitBoard::to_matrix_and_offset Python method
Browse files Browse the repository at this point in the history
  • Loading branch information
nnmm committed Jul 26, 2024
1 parent 8babd2c commit edd0f64
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions gomori/src/board/bitboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,17 @@ mod python {
fn __bool__(&self) -> bool {
!self.is_empty()
}

// Python exclusive
fn to_matrix_and_offset(&self) -> ([[bool; 7]; 7], (i8, i8)) {
let arr = std::array::from_fn(|i_local| {
std::array::from_fn(|j_local| {
let idx = i_local * 7 + j_local;
self.bits & (1u64 << idx) != 0
})
});
(arr, self.offset())
}
}
}

Expand Down

0 comments on commit edd0f64

Please sign in to comment.