コード例 #1
0
 void SetCheckFlags()
 {
     IsCheck     = board.IsCheck();
     IsCheckmate = false;
     IsStalemate = false;
     foreach (string moves in YieldValidMoves())
     {
         return;
     }
     if (IsCheck)
     {
         IsCheckmate = true;
     }
     else
     {
         IsStalemate = true;
     }
 }
コード例 #2
0
ファイル: Chess.cs プロジェクト: evgrussia/Chess-game
 void SetCheckFlags()
 {
     NowColor    = board.moveColor.ToString();
     IsCheck     = board.IsCheck();
     IsCheckMate = false;
     IsStaleMate = false;
     IsDrawSet();
     foreach (string moves in YieldValidMoves())
     {
         return;
     }
     if (IsCheck)
     {
         IsCheckMate = true;
     }
     else
     {
         IsStaleMate = true;
     }
 }
コード例 #3
0
ファイル: Chess.cs プロジェクト: VitaliiKharchuk/ChessEngine
        private void SetChessFlags()
        {
            IsCheck     = Board.IsCheck();
            IsCheckMate = false;
            IsStaleMate = false;

            foreach (var _ in YieldValidMoves())
            {
                return;
            }

            if (IsCheck)
            {
                IsCheckMate = true;
            }
            else
            {
                IsStaleMate = true;
            }
        }
コード例 #4
0
ファイル: Chess.cs プロジェクト: 0gIH04KA/MyChess
        /// <summary>
        ///
        /// установка флагов для проверки шага, мата, пата
        ///
        /// </summary>
        private void SetCheckFlags()
        {
            _isCheck     = _board.IsCheck();
            _isCheckMate = false;
            _isStealMate = false;

            foreach (string moves in YieldValidMoves())
            {
                return;
            }

            if (_isCheck)
            {
                _isCheckMate = true;

                throw new CheckMateException(string.Format($"Color: {_board.MoveColor} - Check Mate"));
            }
            else
            {
                _isStealMate = true;

                throw new StealMateException(string.Format($"Color: {_board.MoveColor} - Steal Mate"));
            }
        }
コード例 #5
0
ファイル: Moves.cs プロジェクト: 0gIH04KA/MyChess
        /// <summary>
        ///
        /// метод который описывает алгоритм рокировки Короля
        ///
        /// </summary>
        /// <returns></returns>
        private bool CanKingCastle()
        {
            //  алгоритм рокировки белого короря
            if (_figureMoving.FigurE == Figure.whiteKing)
            {
                //  короткая рокировка белого короля
                if (_figureMoving.From == new Square("e1"))
                {
                    if (_figureMoving.To == new Square("g1"))
                    {
                        if (_board.CanCastleH1)
                        {
                            if (_board.GetFigureAt(new Square("h1")) == Figure.whiteRook)
                            {
                                if (_board.GetFigureAt(new Square("f1")) == Figure.none)
                                {
                                    if (_board.GetFigureAt(new Square("g1")) == Figure.none)
                                    {
                                        if (!_board.IsCheck())
                                        {
                                            if (!_board.IsCheckAfter(new FigureMoving("Ke1f1")))
                                            {
                                                return(true);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                //  длинная рокировка белого короря
                if (_figureMoving.From == new Square("e1"))
                {
                    if (_figureMoving.To == new Square("c1"))
                    {
                        if (_board.CanCastleA1)
                        {
                            if (_board.GetFigureAt(new Square("a1")) == Figure.whiteRook)
                            {
                                if (_board.GetFigureAt(new Square("b1")) == Figure.none)
                                {
                                    if (_board.GetFigureAt(new Square("c1")) == Figure.none)
                                    {
                                        if (_board.GetFigureAt(new Square("d1")) == Figure.none)
                                        {
                                            if (!_board.IsCheck())
                                            {
                                                if (!_board.IsCheckAfter(new FigureMoving("Ke1d1")))
                                                {
                                                    return(true);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //  алгоритм рокировки черного короля
            if (_figureMoving.FigurE == Figure.blackKing)
            {
                //  короткая рокировка черного короля
                if (_figureMoving.From == new Square("e8"))
                {
                    if (_figureMoving.To == new Square("g8"))
                    {
                        if (_board.CanCastleH8)
                        {
                            if (_board.GetFigureAt(new Square("h8")) == Figure.blackRook)
                            {
                                if (_board.GetFigureAt(new Square("f8")) == Figure.none)
                                {
                                    if (_board.GetFigureAt(new Square("g8")) == Figure.none)
                                    {
                                        if (!_board.IsCheck())
                                        {
                                            if (!_board.IsCheckAfter(new FigureMoving("ke8f8")))
                                            {
                                                return(true);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                //  длинная рокировка черного короля
                if (_figureMoving.From == new Square("e8"))
                {
                    if (_figureMoving.To == new Square("c8"))
                    {
                        if (_board.CanCastleA8)
                        {
                            if (_board.GetFigureAt(new Square("a8")) == Figure.blackRook)
                            {
                                if (_board.GetFigureAt(new Square("b8")) == Figure.none)
                                {
                                    if (_board.GetFigureAt(new Square("c8")) == Figure.none)
                                    {
                                        if (_board.GetFigureAt(new Square("d8")) == Figure.none)
                                        {
                                            if (!_board.IsCheck())
                                            {
                                                if (!_board.IsCheckAfter(new FigureMoving("ke8d8")))
                                                {
                                                    return(true);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(false);
        }
コード例 #6
0
        bool CanKingCastle()
        {
            if (fm.figure == Figure.whiteKing)
            {
                if (fm.from == new Square("e1"))
                {
                    if (fm.to == new Square("g1"))
                    {
                        if (board.canCastleH1)
                        {
                            if (board.GetFigureAt(new Square("h1")) == Figure.whiteRook)
                            {
                                if (board.GetFigureAt(new Square("f1")) == Figure.none)
                                {
                                    if (board.GetFigureAt(new Square("g1")) == Figure.none)
                                    {
                                        if (!board.IsCheck())
                                        {
                                            if (!board.IsCheckAfter(new FigureMoving("Ke1f1")))
                                            {
                                                return(true);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                if (fm.from == new Square("e1"))
                {
                    if (fm.to == new Square("c1"))
                    {
                        if (board.canCastleA1)
                        {
                            if (board.GetFigureAt(new Square("a1")) == Figure.whiteRook)
                            {
                                if (board.GetFigureAt(new Square("b1")) == Figure.none)
                                {
                                    if (board.GetFigureAt(new Square("c1")) == Figure.none)
                                    {
                                        if (board.GetFigureAt(new Square("d1")) == Figure.none)
                                        {
                                            if (!board.IsCheck())
                                            {
                                                if (!board.IsCheckAfter(new FigureMoving("Ke1d1")))
                                                {
                                                    return(true);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (fm.figure == Figure.blackKing)
            {
                if (fm.from == new Square("e8"))
                {
                    if (fm.to == new Square("g8"))
                    {
                        if (board.canCastleH8)
                        {
                            if (board.GetFigureAt(new Square("h8")) == Figure.blackRook)
                            {
                                if (board.GetFigureAt(new Square("f8")) == Figure.none)
                                {
                                    if (board.GetFigureAt(new Square("g8")) == Figure.none)
                                    {
                                        if (!board.IsCheck())
                                        {
                                            if (!board.IsCheckAfter(new FigureMoving("ke8f8")))
                                            {
                                                return(true);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                if (fm.figure == Figure.blackKing)
                {
                    if (fm.from == new Square("e8"))
                    {
                        if (fm.to == new Square("c8"))
                        {
                            if (board.canCastleA8)
                            {
                                if (board.GetFigureAt(new Square("a8")) == Figure.blackRook)
                                {
                                    if (board.GetFigureAt(new Square("b8")) == Figure.none)
                                    {
                                        if (board.GetFigureAt(new Square("c8")) == Figure.none)
                                        {
                                            if (board.GetFigureAt(new Square("d8")) == Figure.none)
                                            {
                                                if (!board.IsCheck())
                                                {
                                                    if (!board.IsCheckAfter(new FigureMoving("ke8d8")))
                                                    {
                                                        return(true);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(false);
        }
コード例 #7
0
ファイル: Chess.cs プロジェクト: gnandyil/GameChess
 public bool IsCheck()
 {
     return(board.IsCheck());
 }