コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IncrementalEvaluationData"/> class.
 /// </summary>
 /// <param name="incrementalEvaluationData">The incremental evaluation data container.</param>
 public IncrementalEvaluationData(IncrementalEvaluationData incrementalEvaluationData)
 {
     WhiteMaterial = incrementalEvaluationData.WhiteMaterial;
     BlackMaterial = incrementalEvaluationData.BlackMaterial;
     Position      = incrementalEvaluationData.Position;
     Castling      = incrementalEvaluationData.Castling;
 }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Bitboard"/> class.
        /// </summary>
        /// <param name="bitboard">The previous bitboard to copy.</param>
        public Bitboard(Bitboard bitboard) : this()
        {
            Hash            = bitboard.Hash;
            GamePhase       = bitboard.GamePhase;
            ReversibleMoves = bitboard.ReversibleMoves;

            Buffer.BlockCopy(bitboard.Pieces, 0, Pieces, 0, bitboard.Pieces.Length * sizeof(ulong));
            Buffer.BlockCopy(bitboard.CastlingPossibility, 0, CastlingPossibility, 0, bitboard.CastlingPossibility.Length * sizeof(bool));
            Buffer.BlockCopy(bitboard.CastlingDone, 0, CastlingDone, 0, bitboard.CastlingDone.Length * sizeof(bool));
            Buffer.BlockCopy(bitboard.Occupancy, 0, Occupancy, 0, bitboard.Occupancy.Length * sizeof(ulong));
            Buffer.BlockCopy(bitboard.EnPassant, 0, EnPassant, 0, bitboard.EnPassant.Length * sizeof(ulong));
            Buffer.BlockCopy(bitboard.History, 0, History, 0, bitboard.History.Length * sizeof(ulong));

            IncEvaluation = new IncrementalEvaluationData(bitboard.IncEvaluation);
            CalculateGamePhase();
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Bitboard"/> class.
        /// </summary>
        /// <param name="friendlyBoard">The friendly board.</param>
        public Bitboard(FriendlyBoard friendlyBoard) : this()
        {
            Pieces = friendlyBoard.GetPiecesArray();
            CastlingPossibility = friendlyBoard.GetCastlingPossibilityArray();
            CastlingDone        = friendlyBoard.GetCastlingDoneArray();
            EnPassant           = friendlyBoard.GetEnPassantArray();
            Occupancy           = CalculateOccupancy();

            Calculate(GeneratorMode.CalculateAttacks, false);
            IncEvaluation = new IncrementalEvaluationData(GetDetailedEvaluation());
            ClearCalculatedData();

            Hash = GetNewHash();
            CalculateGamePhase();

            var random64 = new Random64();

            for (var i = 0; i < History.Length; i++)
            {
                History[i] = random64.Next();
            }
        }
コード例 #4
0
        private void CalculateGamePhase()
        {
            GamePhase updatedGamePhase;

            if (IncEvaluation.WhiteMaterial - MaterialValues.PieceValues[(int)PieceType.King] < 1500 ||
                IncEvaluation.BlackMaterial - MaterialValues.PieceValues[(int)PieceType.King] < 1500)
            {
                updatedGamePhase = GamePhase.End;
            }
            else
            {
                updatedGamePhase = GamePhase.Regular;
            }

            if (GamePhase != updatedGamePhase)
            {
                GamePhase = updatedGamePhase;

                Calculate(GeneratorMode.CalculateAttacks, false);
                IncEvaluation = new IncrementalEvaluationData(GetDetailedEvaluation());
                ClearCalculatedData();
            }
        }