Ejemplo n.º 1
0
        private ChessDraw[] generateDraws(IChessBoard board, ChessDraw?lastDraw = null)
        {
            ChessDraw[] draws       = new ChessDraw[0];
            var         drawingSide = lastDraw?.DrawingSide.Opponent() ?? ChessColor.White;

            if (board?.GetType() == typeof(ChessBoard))
            {
                var alliedPieces = board.GetPiecesOfColor(drawingSide);
                draws = alliedPieces.SelectMany(x => ChessDrawGenerator.Instance.GetDraws(board, x.Position, lastDraw, true)).ToArray();
            }
            else if (board?.GetType() == typeof(ChessBitboard))
            {
                draws = ((ChessBitboard)board).GetAllDraws(drawingSide, lastDraw, true);
            }

            return(draws);
        }