Пример #1
0
        public static BitBoard CopyFigureValues(BitBoard BoardToCopy)
        {
            BitBoard newBoard = new BitBoard();

            newBoard.WhiteKing           = BoardToCopy.WhiteKing;
            newBoard.WhiteQueens         = BoardToCopy.WhiteQueens;
            newBoard.WhiteRooks          = BoardToCopy.WhiteRooks;
            newBoard.WhiteBishops        = BoardToCopy.WhiteBishops;
            newBoard.WhiteKnights        = BoardToCopy.WhiteKnights;
            newBoard.WhitePawns          = BoardToCopy.WhitePawns;
            newBoard.BlackKing           = BoardToCopy.BlackKing;
            newBoard.BlackQueens         = BoardToCopy.BlackQueens;
            newBoard.BlackRooks          = BoardToCopy.BlackRooks;
            newBoard.Blackbishops        = BoardToCopy.Blackbishops;
            newBoard.BlackKnights        = BoardToCopy.BlackKnights;
            newBoard.BlackPawns          = BoardToCopy.BlackPawns;
            newBoard.EnPassantBlack      = BoardToCopy.EnPassantBlack;
            newBoard.EnPassantWhite      = BoardToCopy.EnPassantWhite;
            newBoard.WhiteKingMoved      = BoardToCopy.WhiteKingMoved;
            newBoard.BalckKingMoved      = BoardToCopy.BalckKingMoved;
            newBoard.BlackLeftRookMoved  = BoardToCopy.BlackLeftRookMoved;
            newBoard.BlackRightRookMoved = BoardToCopy.BlackRightRookMoved;
            newBoard.WhiteLeftRookMoved  = BoardToCopy.WhiteLeftRookMoved;
            newBoard.WhiteLeftRookMoved  = BoardToCopy.WhiteLeftRookMoved;
            return(newBoard);
        }
Пример #2
0
        /// <summary>
        /// Returns a new Bitboard with default values for all Figures.NOTE: The helper boards are EMPTY!
        /// </summary>
        /// <returns>New Bitboard with FigureValues</returns>
        public static BitBoard CreateDefaultBoard()
        {
            BitBoard newBoard = new BitBoard();

            newBoard.WhiteKing    = Defaults.WhiteKing;
            newBoard.WhiteQueens  = Defaults.WhiteQueens;
            newBoard.WhiteRooks   = Defaults.WhiteRooks;
            newBoard.WhiteBishops = Defaults.WhiteBishops;
            newBoard.WhiteKnights = Defaults.WhiteKnights;
            newBoard.WhitePawns   = Defaults.WhitePawns;
            newBoard.BlackKing    = Defaults.BlackKing;
            newBoard.BlackQueens  = Defaults.BlackQueens;
            newBoard.BlackRooks   = Defaults.BlackRooks;
            newBoard.Blackbishops = Defaults.Blackbishops;
            newBoard.BlackKnights = Defaults.BlackKnights;
            newBoard.BlackPawns   = Defaults.BlackPawns;
            return(newBoard);
        }
Пример #3
0
 public void AddHistory(GameInfo Info, BitBoard Move)
 {
     this.history[Info].Add(BitBoard.CopyFigureValues(Move));
     this.activeColor *= -1;
 }
Пример #4
0
        public bool LoadHistoryFromDisk(string PathToLoad)
        {
            bool result = false;

            if (!string.IsNullOrEmpty(PathToLoad))
            {
                if (File.Exists(PathToLoad))
                {
                    this.history.Clear();
                    using (StreamReader sr = new StreamReader(PathToLoad, Encoding.UTF8))
                    {
                        GameInfo info  = (GameInfo)DeserializeObject(sr.ReadLine());
                        BitBoard board = new BitBoard();
                        this.history.Add(info, new List <BitBoard>());
                        int amount = 0;
                        if (int.TryParse(sr.ReadLine(), out amount))
                        {
                            for (int step = 0; step < amount; ++step)
                            {
                                board.WhiteKing           = UInt64.Parse(sr.ReadLine());
                                board.WhiteQueens         = UInt64.Parse(sr.ReadLine());
                                board.WhiteRooks          = UInt64.Parse(sr.ReadLine());
                                board.WhiteBishops        = UInt64.Parse(sr.ReadLine());
                                board.WhiteKnights        = UInt64.Parse(sr.ReadLine());
                                board.WhitePawns          = UInt64.Parse(sr.ReadLine());
                                board.EnPassantWhite      = UInt64.Parse(sr.ReadLine());
                                board.BlackKing           = UInt64.Parse(sr.ReadLine());
                                board.BlackQueens         = UInt64.Parse(sr.ReadLine());
                                board.BlackRooks          = UInt64.Parse(sr.ReadLine());
                                board.Blackbishops        = UInt64.Parse(sr.ReadLine());
                                board.BlackKnights        = UInt64.Parse(sr.ReadLine());
                                board.BlackPawns          = UInt64.Parse(sr.ReadLine());
                                board.EnPassantBlack      = UInt64.Parse(sr.ReadLine());
                                board.BalckKingMoved      = sr.ReadLine() == "1" ? true : false;
                                board.WhiteKingMoved      = sr.ReadLine() == "1" ? true : false;
                                board.BlackLeftRookMoved  = sr.ReadLine() == "1" ? true : false;
                                board.BlackRightRookMoved = sr.ReadLine() == "1" ? true : false;
                                board.WhiteLeftRookMoved  = sr.ReadLine() == "1" ? true : false;
                                board.WhiteRightRookMoved = sr.ReadLine() == "1" ? true : false;
                                this.history[info].Add(BitBoard.CopyFigureValues(board));
                            }
                            this.activeColor = int.Parse(sr.ReadLine());
                            //Current state
                            board.WhiteKing           = UInt64.Parse(sr.ReadLine());
                            board.WhiteQueens         = UInt64.Parse(sr.ReadLine());
                            board.WhiteRooks          = UInt64.Parse(sr.ReadLine());
                            board.WhiteBishops        = UInt64.Parse(sr.ReadLine());
                            board.WhiteKnights        = UInt64.Parse(sr.ReadLine());
                            board.WhitePawns          = UInt64.Parse(sr.ReadLine());
                            board.EnPassantWhite      = UInt64.Parse(sr.ReadLine());
                            board.BlackKing           = UInt64.Parse(sr.ReadLine());
                            board.BlackQueens         = UInt64.Parse(sr.ReadLine());
                            board.BlackRooks          = UInt64.Parse(sr.ReadLine());
                            board.Blackbishops        = UInt64.Parse(sr.ReadLine());
                            board.BlackKnights        = UInt64.Parse(sr.ReadLine());
                            board.BlackPawns          = UInt64.Parse(sr.ReadLine());
                            board.EnPassantBlack      = UInt64.Parse(sr.ReadLine());
                            board.BalckKingMoved      = sr.ReadLine() == "1" ? true : false;
                            board.WhiteKingMoved      = sr.ReadLine() == "1" ? true : false;
                            board.BlackLeftRookMoved  = sr.ReadLine() == "1" ? true : false;
                            board.BlackRightRookMoved = sr.ReadLine() == "1" ? true : false;
                            board.WhiteLeftRookMoved  = sr.ReadLine() == "1" ? true : false;
                            board.WhiteRightRookMoved = sr.ReadLine() == "1" ? true : false;
                            this.history[info].Add(BitBoard.CopyFigureValues(board));

                            result = true;
                        }
                        else
                        {
                            throw new Exception("Invalid save file");
                        }
                    }
                }
            }
            return(result);
        }