Exemple #1
0
 Chess(Board board)
 {
     this.board = board;
     this.fen   = board.fen;
     moves      = new Moves(board);
 }
Exemple #2
0
 //rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 - начальная игра
 //rnb1kbnr/pppp1ppp/4p3/8/5PPq/8/PPPPP2P/RNBQKBNR w - - 0 3 - Дурацкий мат
 //rnb1kbnr/pppp1ppp/4p3/8/4PP1q/8/PPPP2PP/RNBQKBNR w - - 0 3 - Дурацкий мат(ошибка)
 public Chess(string fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1")
 {
     this.fen = fen;
     board    = new Board(fen);
     moves    = new Moves(board);
 }
Exemple #3
0
 private Chess(Board board)
 {
     this._board = board;
     Fen         = board.Fen;
     _moves      = new Moves(board);
 }
Exemple #4
0
 public Chess(string fen = startFen)
 {
     this.fen = fen;
     board    = new Board(fen);
     moves    = new Moves(board);
 }
Exemple #5
0
        static void Main(string[] args)
        {
            RenderBoard   renderboard   = new RenderBoard(board);
            UserInput     userinput     = new UserInput();
            Pieces        pieces        = new Pieces();
            bool          whoseTurn     = true; //white - true, black - false
            Transform     transform     = new Transform();
            PossbileMoves possiblemoves = new PossbileMoves();
            Moves         moves         = new Moves();
            string        attackedTiles = "AA";

            string movesInt = "";

            //renderboard.CostumBoard(board);
            while (true) // to be changed to IsGameOver method
            {
                attackedTiles = "AA";
                int        posToWhichMove, posOfPiece;
                ChessBoard piece;
                //renderboard.CostumBoard(board); //DEBUG
                renderboard.Render(board);
                Coms.RenderComs(1);
                posOfPiece = userinput.GetInput();
                if (!pieces.IsPlayerPiece(board[posOfPiece / 10, posOfPiece % 10], whoseTurn))
                {
                    Coms.RenderComs(6);
                    continue;
                }
                Coms.RenderComs(3);
                posToWhichMove = userinput.GetInput(); // get input to where should the piece be moved
                movesInt       = ListMoves.RememberAsInt(posToWhichMove / 10, posToWhichMove % 10, movesInt);


                if (moves.Controller(board, posToWhichMove / 10, posToWhichMove % 10, posOfPiece / 10, posOfPiece % 10, whoseTurn, movesInt).IndexOf(posToWhichMove.ToString()) != -1)
                {
                    ChessBoard[,] copyOfBoard = new ChessBoard[8, 8];
                    for (int i = 0; i < 8; i++)
                    {
                        for (int j = 0; j < 8; j++)
                        {
                            copyOfBoard[i, j] = board[i, j];
                        }
                    }
                    moves.ExecuteMove(copyOfBoard, posToWhichMove / 10, posToWhichMove % 10, posOfPiece / 10, posOfPiece % 10, whoseTurn);
                    if (whoseTurn)
                    {
                        for (int i = 0; i < 8; i++)
                        {
                            for (int j = 0; j < 8; j++)
                            {
                                if (board[i, j] < 0 && board[i, j] != 0)
                                {
                                    attackedTiles = String.Concat(attackedTiles, transform.TransformFromIntToNotation((moves.ListAttackedTiles(board, i, j, !whoseTurn))));
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < 8; i++)
                        {
                            for (int j = 0; j < 8; j++)
                            {
                                if (board[i, j] > 0 && board[i, j] != 0)
                                {
                                    attackedTiles = String.Concat(attackedTiles, transform.TransformFromIntToNotation((moves.ListAttackedTiles(board, i, j, !whoseTurn))));
                                }
                                //, Console.WriteLine(attackedTiles);
                            }
                        }
                    }
                    //Console.WriteLine(attackedTiles);
                    if (attackedTiles.IndexOf(possiblemoves.SearchForKing(copyOfBoard, whoseTurn)) == -1)
                    {
                    }
                    else
                    {
                        //write funciton that lists all moves white can move and then check if after any of those moves the check is still in place, if it is then game over!!
                        Coms.RenderComs(8);
                        continue;
                    }
                    moves.ExecuteMove(board, posToWhichMove / 10, posToWhichMove % 10, posOfPiece / 10, posOfPiece % 10, whoseTurn);
                }
                else
                {
                    Coms.RenderComs(5);
                    continue;
                }
                if (whoseTurn)
                {
                    whoseTurn = false;
                }
                else
                {
                    whoseTurn = true;
                }
            }
        }
Exemple #6
0
 private Chess(Board board)
 {
     Board = board;
     Fen   = board.Fen;
     Moves = new Moves(Board);
 }