コード例 #1
0
        //Проверка на шах
        public bool IsCheck()
        {
            Color inGameColor            = desk.notation.InGameColor;
            ForsythEdwardsNotation copyN = (ForsythEdwardsNotation)desk.notation.Clone();
            Desk        copyDesk         = new Desk(copyN);
            Moves       copyMoves        = new Moves(copyDesk);
            ChessPlayer op = new Bot(inGameColor.FlipColor(), copyMoves, copyDesk);

            return(copyDesk.IsKingInDanger(copyMoves.GetPlayerMoves(op.playerColor), inGameColor));
        }
コード例 #2
0
        //Начать партию
        internal void StartGame(string fen, Color playerColor)
        {
            notation    = JsonConvert.DeserializeObject <ForsythEdwardsNotation>(fen);
            inGameColor = notation.InGameColor;
            moveNumber  = notation.MoveNumber;
            desk        = new Desk(notation);
            moves       = new Moves(desk);

            if (playerColor == Color.none)
            {
                Color[] colors = new Color[2] {
                    Color.white, Color.black
                };
                playerColor = colors[rnd.Next(0, 2)];
            }

            player1 = new Gamer(playerColor, moves, desk);
            player2 = new Bot(playerColor.FlipColor(), moves, desk);
            moves.InitMoves();
        }
コード例 #3
0
        public bool IsMateAfterMove(string move, Vectors vector)
        {
            bool      result;
            PieceMove pieceMove          = new PieceMove(inGameColor, move);
            ForsythEdwardsNotation copyN = (ForsythEdwardsNotation)desk.notation.Clone();
            Desk  copyDesk  = new Desk(copyN);
            Moves copyMoves = new Moves(copyDesk);

            copyDesk.UpdatePiecesOnDesk(pieceMove, inGameColor);
            ChessPlayer op = new Bot(inGameColor.FlipColor(), copyMoves, copyDesk);

            result = copyDesk.IsKingInDanger(copyMoves.GetPlayerMoves(op.playerColor), inGameColor);

            if (result && vector.status != "recalculate")
            {
                vector.status = "recalculate";
                RecalculatedPiecesPosition.Add(pieceMove.from);
            }
            return(result);
        }
コード例 #4
0
ファイル: Desk.cs プロジェクト: DivanisAnatoly/BWChess
 //Создать доску
 internal Desk(ForsythEdwardsNotation notation)
 {
     this.notation = notation;
     SetPiecesOnDesk(this.notation.PiecePosition);
 }