Skip to content

Commit

Permalink
Pcg update
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis Giagkiozis committed Feb 12, 2017
1 parent 0e09061 commit 0fd4a29
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions CrystalAI/Source/Utilities/PcgExtended.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ namespace Crystal {
/// its weight into a black hole.
/// </summary>
public class PcgExtended {
// This shifted to the left and or'ed with 1ul results in the default increment.
const ulong ShiftedIncrement = 721347520444481703ul;
const ulong Multiplier = 6364136223846793005ul;
const uint PcgMultiplier = 747796405u;
const uint PcgIncrement = 2891336453u;
const uint McgMultiplier = 277803737u;
const uint McgUnmultiplier = 2897767785u;
// 1 / (uint.MaxValue + 1)
const double ToDouble01 = 1.0 / 4294967296.0;

// This attribute ensures that every thread will get its own instance of PCG.
// An alternative, since PCG supports streams, is to use a different stream per
// thread.
Expand Down Expand Up @@ -532,14 +542,14 @@ public bool[] NextBools(int count) {
}

/// <summary>
/// Equidistribution this generator.
/// Equidistribution this generator.
/// </summary>
public int Equidistribution() {
return 1 << _tablePow2;
}

/// <summary>
/// Power of two exponent of the equidistribution of this generator.
/// Power of two exponent of the equidistribution of this generator.
/// </summary>
/// <returns></returns>
public int EquidistributionPow2() {
Expand Down Expand Up @@ -729,17 +739,6 @@ uint UnXorShift(uint x, int bits, int shift) {
bottom2 &= lowmask1;
return top1 | bottom2;
}

// This shifted to the left and or'ed with 1ul results in the default increment.
const ulong ShiftedIncrement = 721347520444481703ul;
const ulong Multiplier = 6364136223846793005ul;
const uint PcgMultiplier = 747796405u;
const uint PcgIncrement = 2891336453u;
const uint McgMultiplier = 277803737u;
const uint McgUnmultiplier = 2897767785u;

// 1 / (uint.MaxValue + 1)
const double ToDouble01 = 1.0 / 4294967296.0;
}

}

0 comments on commit 0fd4a29

Please sign in to comment.