Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let file = (square.0 & 0b0000_0111) as i8;
- let rank = (square.0 >> 3) as i8;
- for &(i, j) in &[(-2, -1), (-2, 1), (-1, -2), (-1, 2),
- (1, -2), (1, 2), (2, -1), (2, 1)] {
- if file + i < 0 || file + i >= 8 || rank + j < 0 || rank + j >= 8 {
- continue;
- }
- let dest_square = Square(((rank + j) * 8 + file + i) as u8)
- if board[dest_square].color() != Some(board.to_move) {
- add_if_legal(board, ChessMove::new(square, dest_square), moves);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement