[position] For non-King move generators, only generate moves if the push and captures masks aren't empty
Always generate King moves.
This commit is contained in:
parent
31903cb514
commit
986758d011
7 changed files with 35 additions and 26 deletions
|
@ -3,13 +3,13 @@
|
|||
use super::{move_generator_declaration, MoveGeneratorInternal, MoveSet};
|
||||
use crate::Position;
|
||||
use chessfriend_bitboard::BitBoard;
|
||||
use chessfriend_core::{Color, Direction, Piece, PlacedPiece};
|
||||
use chessfriend_core::{Direction, PlacedPiece, Shape};
|
||||
|
||||
move_generator_declaration!(ClassicalMoveGenerator);
|
||||
|
||||
impl MoveGeneratorInternal for ClassicalMoveGenerator {
|
||||
fn piece(color: Color) -> Piece {
|
||||
Piece::bishop(color)
|
||||
fn shape() -> Shape {
|
||||
Shape::Bishop
|
||||
}
|
||||
|
||||
fn move_set_for_piece(
|
||||
|
|
|
@ -6,15 +6,15 @@
|
|||
use super::{move_generator_declaration, MoveGeneratorInternal, MoveSet};
|
||||
use crate::{r#move::Castle, Position};
|
||||
use chessfriend_bitboard::BitBoard;
|
||||
use chessfriend_core::{Color, Piece, PlacedPiece};
|
||||
use chessfriend_core::{PlacedPiece, Shape};
|
||||
|
||||
move_generator_declaration!(KingMoveGenerator, struct);
|
||||
move_generator_declaration!(KingMoveGenerator, new);
|
||||
move_generator_declaration!(KingMoveGenerator, getters);
|
||||
|
||||
impl MoveGeneratorInternal for KingMoveGenerator {
|
||||
fn piece(color: Color) -> Piece {
|
||||
Piece::king(color)
|
||||
fn shape() -> Shape {
|
||||
Shape::King
|
||||
}
|
||||
|
||||
fn move_set_for_piece(
|
||||
|
@ -59,7 +59,7 @@ mod tests {
|
|||
use super::*;
|
||||
use crate::{assert_move_list, position, test_position, Move, MoveBuilder, PositionBuilder};
|
||||
use chessfriend_bitboard::bitboard;
|
||||
use chessfriend_core::{piece, Square};
|
||||
use chessfriend_core::{piece, Color, Square};
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
use super::{move_generator_declaration, MoveGeneratorInternal, MoveSet};
|
||||
use crate::Position;
|
||||
use chessfriend_bitboard::BitBoard;
|
||||
use chessfriend_core::{Color, Piece, PlacedPiece};
|
||||
use chessfriend_core::{PlacedPiece, Shape};
|
||||
|
||||
move_generator_declaration!(KnightMoveGenerator);
|
||||
|
||||
impl MoveGeneratorInternal for KnightMoveGenerator {
|
||||
fn piece(color: Color) -> Piece {
|
||||
Piece::knight(color)
|
||||
fn shape() -> Shape {
|
||||
Shape::Knight
|
||||
}
|
||||
|
||||
fn move_set_for_piece(
|
||||
|
@ -35,7 +35,7 @@ impl MoveGeneratorInternal for KnightMoveGenerator {
|
|||
mod tests {
|
||||
use super::*;
|
||||
use crate::{position, Move, MoveBuilder};
|
||||
use chessfriend_core::{piece, Square};
|
||||
use chessfriend_core::{piece, Color, Square};
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use super::{move_generator_declaration, MoveGeneratorInternal, MoveSet};
|
||||
use crate::Position;
|
||||
use chessfriend_bitboard::BitBoard;
|
||||
use chessfriend_core::{Color, Piece, PlacedPiece, Rank, Square};
|
||||
use chessfriend_core::{Piece, PlacedPiece, Rank, Shape, Square};
|
||||
|
||||
#[derive(Debug)]
|
||||
struct MoveIterator(usize, usize);
|
||||
|
@ -11,8 +11,8 @@ struct MoveIterator(usize, usize);
|
|||
move_generator_declaration!(PawnMoveGenerator);
|
||||
|
||||
impl MoveGeneratorInternal for PawnMoveGenerator {
|
||||
fn piece(color: Color) -> Piece {
|
||||
Piece::pawn(color)
|
||||
fn shape() -> Shape {
|
||||
Shape::Pawn
|
||||
}
|
||||
|
||||
fn move_set_for_piece(
|
||||
|
@ -63,7 +63,7 @@ impl PawnMoveGenerator {
|
|||
mod tests {
|
||||
use super::*;
|
||||
use crate::{assert_move_list, position::DiagramFormatter, test_position, Move, MoveBuilder};
|
||||
use chessfriend_core::{piece, Square};
|
||||
use chessfriend_core::{piece, Color, Square};
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
use super::{move_generator_declaration, MoveGeneratorInternal, MoveSet};
|
||||
use crate::Position;
|
||||
use chessfriend_bitboard::BitBoard;
|
||||
use chessfriend_core::{Color, Direction, Piece, PlacedPiece};
|
||||
use chessfriend_core::{Direction, PlacedPiece, Shape};
|
||||
|
||||
move_generator_declaration!(ClassicalMoveGenerator);
|
||||
|
||||
impl MoveGeneratorInternal for ClassicalMoveGenerator {
|
||||
fn piece(color: Color) -> Piece {
|
||||
Piece::queen(color)
|
||||
fn shape() -> Shape {
|
||||
Shape::Queen
|
||||
}
|
||||
|
||||
fn move_set_for_piece(
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
use super::{move_generator_declaration, MoveGeneratorInternal, MoveSet};
|
||||
use crate::Position;
|
||||
use chessfriend_bitboard::BitBoard;
|
||||
use chessfriend_core::{Color, Direction, Piece, PlacedPiece};
|
||||
use chessfriend_core::{Direction, PlacedPiece, Shape};
|
||||
|
||||
move_generator_declaration!(ClassicalMoveGenerator);
|
||||
|
||||
impl MoveGeneratorInternal for ClassicalMoveGenerator {
|
||||
fn piece(color: Color) -> Piece {
|
||||
Piece::rook(color)
|
||||
fn shape() -> Shape {
|
||||
Shape::Rook
|
||||
}
|
||||
|
||||
fn move_set_for_piece(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue