Exemplo n.º 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));
        }
Exemplo n.º 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();
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
 //Создать доску
 internal Desk(ForsythEdwardsNotation notation)
 {
     this.notation = notation;
     SetPiecesOnDesk(this.notation.PiecePosition);
 }