Skip to content

Commit

Permalink
chore: remove the singles function from the common interface
Browse files Browse the repository at this point in the history
  • Loading branch information
raklaptudirm committed Jul 30, 2024
1 parent 164240e commit e6459aa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
7 changes: 6 additions & 1 deletion games/src/ataxx/moves.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
use super::{BitBoard, Square};
use crate::interface::RepresentableType;
use crate::interface::{BitBoardType, RepresentableType};

pub fn singles(bb: BitBoard) -> BitBoard {
let bar = bb | bb.east() | bb.west();
bar | bar.north() | bar.south()
}

/// single returns the targets of a singular Move from the given Square.
/// ```
Expand Down
4 changes: 2 additions & 2 deletions games/src/ataxx/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl PositionType for Position {
// Pieces can only move to unoccupied Squares.
let allowed = !(stm | xtm | gap);

for target in stm.singles() & allowed {
for target in moves::singles(stm) & allowed {
movelist.push(Move::new_single(target));
}

Expand Down Expand Up @@ -261,7 +261,7 @@ impl PositionType for Position {
let allowed = !(stm | xtm | gap);

// Count the number single moves in the Position.
let mut moves: usize = (stm.singles() & allowed).cardinality();
let mut moves: usize = (moves::singles(stm) & allowed).cardinality();

for piece in stm {
// There may be multiple jump moves to a single Square, so they need to be
Expand Down
5 changes: 0 additions & 5 deletions games/src/interface/bitboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@ where
}
}

fn singles(self) -> Self {
let bar: Self = ((self | self.east()).into() | self.west()).into();
((bar | bar.north()).into() | bar.south()).into()
}

/// file returns a Self containing all the squares from the given <Self::Square as Square>::File.
fn file(file: <Self::Square as SquareType>::File) -> Self {
Self::from(Self::FIRST_FILE.into() << file.into())
Expand Down

0 comments on commit e6459aa

Please sign in to comment.