예제 #1
0
        public bool IsCheckAfterMove(FigureMoving fm)
        {
            Board  after       = Move(fm);
            Figure checkedKing = (MoveColor == Color.Black) ? Figure.whiteKing : Figure.blackKing;

            return(after.CanEatKing(whereIsCheckedKing: FindCheckedKing(checkedKing)));
        }
예제 #2
0
 public bool CanMove(FigureMoving fm)
 {
     this.fm = fm;
     return
         (CanMoveFrom() &&
          CanMoveTo() &&
          CanFigureMove());
 }
예제 #3
0
파일: Chess.cs 프로젝트: BlackSemkaJ/Chess
        public Chess Move(string move)  // Метод хода
        {
            FigureMoving fm        = new FigureMoving(move);
            Board        nextBoard = board.Move(fm);
            Chess        nextChess = new Chess(nextBoard);

            return(nextChess);
        }
예제 #4
0
        public Chess Move(string move) // Pe2e4  Pe7e8Q
        {
            FigureMoving fm        = new FigureMoving(move);
            Board        nextBoard = board.Move(fm);
            Chess        nextChess = new Chess(nextBoard);

            return(nextChess);
        }
예제 #5
0
        public Chess Move(string move)                       // Pe2e4 - (пешка)P(от)e2(к)e4, Pe7e8Q - (пешка)P(от)e7(к)e8(превращается в ферзя)Q.
        {
            FigureMoving fm        = new FigureMoving(move); // Передаем параметр движения фигуры и получаем сущьность описывающую перемещение фигуры.
            Board        nextBoard = board.Move(fm);         // Записываем новую доску в новую сущьность новой доски учитывая ход.
            Chess        nextChess = new Chess(nextBoard);

            return(nextChess);
        }
예제 #6
0
파일: Chess.cs 프로젝트: AlexandrSHad/Chess
        public Chess Move(string move) // Pe2e4, Pe7e8Q
        {
            var fm        = new FigureMoving(move);
            var nextBoard = board.Move(fm);
            var nextChess = new Chess(nextBoard);

            return(nextChess);
        }
예제 #7
0
        public bool CanMove(FigureMoving fm)
        {
            this._fm = fm;

            var From       = CanMoveFrom(_fm.To.OnBoard());
            var To         = CanMoveTo(_fm.To.OnBoard());
            var FigureMove = CanFigureMove();

            return(From && To && FigureMove);
        }
예제 #8
0
        // For realize moving
        public Board Move(FigureMoving fm)
        {
            var next = new Board(Fen);

            next.SetFigureAt(fm.From, Figure.none);
            next.SetFigureAt(fm.To, CheckingOnPromotion(fm));

            ChangingMoveNumberAndFlipColor(next);
            next.GenerateFen();
            return(next);
        }
예제 #9
0
        public Chess Move(string move) // Pe2e4    Pe7e8Q
        {
            // сгенерировали новый ход, передаем ход
            FigureMoving fm = new FigureMoving(move);
            // создаем следующую доску принимающую следующий ход
            Board nextBoard = board.Move(fm);
            // новые шахматы создаются не от фен а от новой доски
            Chess nextChess = new Chess(nextBoard);

            return(nextChess);
        }
예제 #10
0
        public Chess Move(string move) // Pe2e4
        {
            FigureMoving fm = new FigureMoving(move);

            if (!moves.CanMove(fm))
            {
                return(this);
            }
            Board nextBoard = board.Move(fm);
            Chess nextChess = new Chess(nextBoard);

            return(nextChess);
        }
        public Chess Move(string move) //Pe2e4. P - пешка. e2 - начальная позиция. е4 - конечная.
        {
            FigureMoving fm = new FigureMoving(move);

            if (!moves.CanMove(fm))
            {
                return(this);
            }
            Board nextBoard = board.Move(fm);
            Chess nextChess = new Chess(nextBoard);

            return(nextChess);
        }
예제 #12
0
        public Board Move(FigureMoving fm)                                                   // Создает новую доску с учетом нового хода.
        {
            Board next = new Board(fen);                                                     // Новая доска

            next.SetFigureAt(fm.from, Figure.none);                                          // Удаляет фигуру из того места от куда она делает ход.
            next.SetFigureAt(fm.to, fm.promotion == Figure.none ? fm.figure : fm.promotion); // Отправляет фигу на нужную клетку, в случае трансформации меняет фигуру
            if (moveColor == Color.black)
            {
                next.moveNumber++;
            }
            next.moveColor = moveColor.FlipColor(); // Меняем цвет ходящих фигур.
            return(next);
        }
예제 #13
0
파일: Board.cs 프로젝트: ssauew/game_chess
        public Board Move(FigureMoving fm)//реализация самого хода фигуры
        {
            Board next = new Board(fen);

            next.SetFigureAt(fm.from, Figure.none);
            next.SetFigureAt(fm.to, fm.promotion == Figure.none ? fm.figure : fm.promotion);
            if (moveColor == Color.black)
            {
                next.moveNumber++;
            }
            next.moveColor = moveColor.FlipColor();
            next.GenerateFen(); //для сохранения ходов всех фигур
            return(next);
        }
예제 #14
0
        public Board Move(FigureMoving fm)
        {
            var next = new Board(fen);

            next.SetFigureAt(fm.from, Figure.none);
            next.SetFigureAt(fm.to, fm.promotion == Figure.none ? fm.figure : fm.promotion);
            if (moveColor == Color.black)
            {
                next.moveNumber++;
            }
            next.moveColor = moveColor.SwitchColor();
            next.GetFen();
            return(next);
        }
예제 #15
0
        private bool CanEatKing(Square whereIsCheckedKing)
        {
            Moves moves = new Moves(this);

            foreach (FigureOnSquare fs in YieldFigures())
            {
                FigureMoving fm = new FigureMoving(fs, whereIsCheckedKing);
                if (moves.CanMove(fm))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #16
0
        public Board Move(FigureMoving fm)
        {
            Board next = new Board(fen);

            next.SetFigureAt(fm.from, Figure.none);
            next.SetFigureAt(fm.to, fm.promotion == Figure.none ? fm.figure : fm.promotion);
            if (moveColor == Color.black)
            {
                next.moveNumber++;
            }
            next.moveColor = moveColor.FlipColor();
            next.GenerateFEN();
            return(next);
        }
예제 #17
0
        bool CanKingGo(Square fl, Board board)
        {
            Moves          moves = new Moves(board);
            FigureOnSquare fs    = new FigureOnSquare(moveColor == Color.white ? Figure.whiteKing : Figure.blackKing, fl);

            foreach (Square to in Square.YieldSquares())
            {
                FigureMoving fm = new FigureMoving(fs, to);
                if (moves.CanMove(fm))
                {
                    return(true);
                }
            }
            return(false);
        }
 void FindAllMoves()
 {
     allMoves = new List <FigureMoving>();
     foreach (FigureOnSquare fs in board.YieldFigures())
     {
         foreach (Square to in Square.YieldSquares())
         {
             FigureMoving fm = new FigureMoving(fs, to);
             if (moves.CanMove(fm))
             {
                 allMoves.Add(fm);
             }
         }
     }
 }
예제 #19
0
파일: Board.cs 프로젝트: ssauew/game_chess
        bool CanEatKing()
        {
            Square badKing = FindBadKing();               //найти короля
            Moves  moves   = new Moves(this);             //найти доступные ходы

            foreach (FigureOnSquare fs in YieldFigures()) //перебор фигур
            {
                FigureMoving fm = new FigureMoving(fs, badKing);
                if (moves.CanMove(fm))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #20
0
        bool CanEatKing()
        {
            Square badKing = FindBadKing();
            Moves  moves   = new Moves(this);

            foreach (FigureOnSquare fs in YieldFigures())
            {
                FigureMoving fm = new FigureMoving(fs, badKing);
                if (moves.CanMove(fm))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #21
0
        public Board Move(FigureMoving fm)
        {
            Board next = new Board(Fen);

            next.SetFigureAt(fm.From, Figure.None);
            next.SetFigureAt(fm.To, fm.Promotion == Figure.None ? fm.Figure : fm.Promotion);
            if (MoveColor == Color.Black)
            {
                next.MoveNumber++;
            }

            next.MoveColor = MoveColor.FlipColor();
            next.GenerateFen();
            return(next);
        }
예제 #22
0
        private bool CanEatKing()
        {
            var badKing = FindBadKing();
            var moves   = new Moves(this);

            foreach (var fs in YieldFigures())
            {
                var fm = new FigureMoving(fs, badKing);
                if (moves.CanMove(fm))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #23
0
        public Chess Move(string move)
        {
            FigureMoving fm = new FigureMoving(move);

            if (!moves.CanMove(fm))
            {
                return(this);
            }
            if (!board.IsCheckAfterMove(fm))
            {
                return(this);
            }

            Board nextBoard = board.Move(fm);

            return(new Chess(nextBoard));
        }
예제 #24
0
        public Chess Move(string move) // Pe2e4         Pe7e8Q
        {
            var fm = new FigureMoving(move);

            if (_moves.CanMove(fm) == false)
            {
                return(this);
            }
            if (_board.IsCheckAfterMove(fm) == true)
            {
                return(this);
            }
            Board nextBoard = _board.Move(fm);
            var   nextChess = new Chess(nextBoard);

            return(nextChess);
        }
예제 #25
0
파일: Chess.cs 프로젝트: ValikSk8er/chess
        public Chess Move(string move) // Pe2e4 Pe7e8Q
        {
            FigureMoving fm = new FigureMoving(move);

            if (!this.moves.CanMove(fm))
            {
                return(this);
            }
            if (this.board.IsCheckAfterMove(fm))
            {
                return(this);
            }
            Board nextBoard = board.Move(fm);
            Chess nextChess = new Chess(nextBoard);

            return(nextChess);
        }
예제 #26
0
        public Chess Move(string move)  // Figure_name + start position + end position
        {
            FigureMoving fm = new FigureMoving(move);

            if (!moves.canMove(fm))
            {
                return(this);
            }
            if (board.IsCheckAfterMove(fm))
            {
                return(this);
            }
            Board nextBoard = board.Move(fm);
            Chess nextChess = new Chess(nextBoard);

            return(nextChess);
        }
예제 #27
0
파일: Chess.cs 프로젝트: ssauew/game_chess
        /*******************/

        //делается ход фигуры
        public Chess Move(string move)                // Pe2e4   Pe7e8Q
        {
            FigureMoving fm = new FigureMoving(move); //figure from to promotion

            if (!moves.CanMove(fm))
            {
                return(this);
            }
            if (board.IsCheckAfterMove(fm))//
            {
                return(this);
            }
            Board nextBoard = board.Move(fm);       //реализация самого хода фигуры
            Chess nextChess = new Chess(nextBoard); //инфа о параметрах и реализации хода

            return(nextChess);
        }
예제 #28
0
        public Chess Move(string move)
        {
            var fm = new FigureMoving(move);

            if (!Moves.CanMove(fm))
            {
                return(this);
            }
            if (Board.IsCheckAfterMove(fm))
            {
                return(this);
            }
            var nextBoard = Board.Move(fm);
            var nextChess = new Chess(nextBoard);

            return(nextChess);
        }
예제 #29
0
파일: Chess.cs 프로젝트: ValikSk8er/chess
 void FindAllMoves()
 {
     this.allMoves = new List <FigureMoving>();
     foreach (FigureOnSquare fs in this.board.YieldFigures())
     {
         foreach (Square to in Square.YieldSquares())
         {
             FigureMoving fm = new FigureMoving(fs, to);
             if (this.moves.CanMove(fm))
             {
                 if (!this.board.IsCheckAfterMove(fm))
                 {
                     this.allMoves.Add(fm);
                 }
             }
         }
     }
 }
예제 #30
0
파일: Chess.cs 프로젝트: ssauew/game_chess
 void FindAllMoves()
 {
     allMoves = new List <FigureMoving>();
     foreach (FigureOnSquare fs in board.YieldFigures()) //перебор фигур того цвета, которые щас ходят
     {
         foreach (Square to in Square.YieldSquares())    //перебор клеток, куда может пойти фигура
         {
             FigureMoving fm = new FigureMoving(fs, to);
             if (moves.CanMove(fm))
             {
                 if (!board.IsCheckAfterMove(fm))
                 {
                     allMoves.Add(fm);
                 }
             }
         }
     }
 }