Example #1
0
        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);
        }
Example #2
0
        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;
        }
Example #3
0
 public RulesExpert()
 {
     _kingMoveExpert   = new KingMoveExpert();
     _queenMoveExpert  = new QueenMoveExpert();
     _rookMoveExpert   = new RookMoveExpert();
     _bishopMoveExpert = new BishopMoveExpert();
     _knightMoveExpert = new KnightMoveExpert();
     _pawnMoveExpert   = new PawnMoveExpert();
 }
Example #4
0
        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);
        }