Beispiel #1
0
        public bool Do(Move move)
        {
            Piece piece = Get(move.GetFirstSource());

            if (piece.IsPossible(move))
            {
                Console.WriteLine(AlgebraicNotation(move));
                moves.Add(move);
                turn = turn.Other();
                ExecuteMove(move);
                Print();
                System.Console.WriteLine();
                System.Console.WriteLine(ToFen());
                return(true);
            }
            return(false);
        }
Beispiel #2
0
        // Returns true if any of the pieces of a given color have a valid move.
        private bool CheckHasLegalMoves(PieceColor color)
        {
            var pieces = GetAlive(color);

            foreach (var piece in pieces)
            {
                foreach (var move in piece.GetPossibleMoves())
                {
                    PerformMove(piece, move.Item1, move.Item2);
                    var check = CheckCheck(color.Other());
                    PerformUndoMove();
                    if (check.Count == 0)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }