private BaseMoveExpert GetMoveExpert(PieceType pieceType) { BaseMoveExpert moveExpert = null; switch (pieceType) { case PieceType.King: moveExpert = _kingMoveExpert; break; case PieceType.Queen: moveExpert = _queenMoveExpert; break; case PieceType.Rook: moveExpert = _rookMoveExpert; break; case PieceType.Bishop: moveExpert = _bishopMoveExpert; break; case PieceType.Knight: moveExpert = _knightMoveExpert; break; case PieceType.Pawn: moveExpert = _pawnMoveExpert; break; } return(moveExpert); }
public void PerformMove(Position position, Move move) { BaseMoveExpert moveExpert = GetMoveExpert(move.Piece.Type); moveExpert.PerformMove(position, move); position.SideToMove = position.SideToMove == Color.White ? Color.Black : Color.White; }
public RulesExpert() { _kingMoveExpert = new KingMoveExpert(); _queenMoveExpert = new QueenMoveExpert(); _rookMoveExpert = new RookMoveExpert(); _bishopMoveExpert = new BishopMoveExpert(); _knightMoveExpert = new KnightMoveExpert(); _pawnMoveExpert = new PawnMoveExpert(); }
public bool IsLegalMove(Position position, Move move) { bool isLegal; BaseMoveExpert moveExpert = GetMoveExpert(move.Piece.Type); if (moveExpert != null) { isLegal = moveExpert.IsLegalMove(position, move); } else { isLegal = false; } return(isLegal); }