/** * Constructor that hashes seed with {@link CrossHash#hash64(CharSequence)} and uses the result as the state. * @param seed any CharSequence, such as a String or StringBuilder; should probably not be null (it might work?) */ public LinnormRNG(final CharSequence seed) { state = CrossHash.hash64(seed); }
/** * String-seeded constructor uses the hash of the String as a seed for LightRNG, which is of high quality, but low * period (which rarely matters for games), and has good speed and tiny state size. * * @param seedString a String to use as a seed; will be hashed in a uniform way across platforms. */ public DeckRNG(CharSequence seedString) { this(CrossHash.hash64(seedString)); } /**
/** * String-seeded constructor; uses a platform-independent hash of the String (it does not use String.hashCode) as a * seed for this RNG. * @param seedString any CharSequence, such as a String or StringBuilder; if null this will use the seed 0 */ public MoonwalkRNG(CharSequence seedString) { this(CrossHash.hash64(seedString)); }
/** * Creates a new probability table with the provided String seed used. * * @param seed the RNG seed as a String */ public ProbabilityTable(String seed) { this(CrossHash.hash64(seed)); }
public static long hash64(final Iterable<? extends CharSequence> data) { if (data == null) return 0L; long result = 0x1A976FDF6BF60B8EL, z = 0x60642E2A34326F15L; for (CharSequence datum : data) { result ^= (z += (hash64(datum) ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL); result = (result << 54 | result >>> 10); } result += (z ^ z >>> 26) * 0x632BE59BD9B4E019L; result = (result ^ result >>> 33) * 0xFF51AFD7ED558CCDL; return ((result ^ result >>> 33) * 0xC4CEB9FE1A85EC53L); }
public static long hash64(final long[][] data) { if (data == null) return 0L; long result = 0x1A976FDF6BF60B8EL, z = 0x60642E2A34326F15L; final int len = data.length; for (int i = 0; i < len; i++) { result ^= (z += (hash64(data[i]) ^ 0xC6BC279692B5CC85L) * 0x6C8E9CF570932BABL); result = (result << 54 | result >>> 10); } result += (z ^ z >>> 26) * 0x632BE59BD9B4E019L; result = (result ^ result >>> 33) * 0xFF51AFD7ED558CCDL; return ((result ^ result >>> 33) * 0xC4CEB9FE1A85EC53L); }
public long hash64() { return 31L * CrossHash.hash64(key) + size; }
public SpillWorldMap() { width = 20; height = 20; name = "Permadeath Island"; rng = new StatefulRNG(CrossHash.hash64(name)); } /**
/** * Makes a CriticalRNG with a luck factor of 0 and a DiverRNG with the given seed for its RandomnessSource (this * will hash seedString using {@link CrossHash#hash64(CharSequence)} and use the result to seed the DiverRNG). * @param seedString any String * @param luck typically a small float, often between -0.5f and 0.5f, that will affect the results this returns */ public CriticalRNG(CharSequence seedString, float luck) { super(new DiverRNG(CrossHash.hash64(seedString))); this.luck = luck; }
public long hash64() { long result = CrossHash.hash64(primary), a = 0x632BE59BD9B4E019L; if(associated == null) return result ^ a; final int len = associated.size(); for (int i = 0; i < len; i++) { result += (a ^= 0x8329C6EB9E6AD3E3L * associated.get(i).hash64()); } return result * (a | 1L) ^ (result >>> 27 | result << 37); }
/** * String-seeded constructor; uses a platform-independent hash of the String (it does not use String.hashCode, * instead using {@link CrossHash#hash64(CharSequence)}) as a seed for {@link DiverRNG}, which is of high quality, * but low period (which rarely matters for games), and has excellent speed, tiny state size, and natively generates * 64-bit numbers. */ public RNG(CharSequence seedString) { this(new DiverRNG(CrossHash.hash64(seedString))); }
public PoliticalMapper() { name = "Permadeath Planet"; rng = new StatefulRNG(CrossHash.hash64(name)); } /**
/** * Makes a CriticalRNG with a luck factor of 0 and a DiverRNG with the given seed for its RandomnessSource (this * will hash seedString using {@link CrossHash#hash64(CharSequence)} and use the result to seed the DiverRNG). * @param seedString any String */ public CriticalRNG(CharSequence seedString) { super(new DiverRNG(CrossHash.hash64(seedString))); }
/** * Constructs a SpillWorldMap using the given world name, and uses the world name as the * basis for all future random generation in this object. * * @param worldName a String name for the world that will be used as a seed for all random generation here */ public PoliticalMapper(String worldName) { name = worldName; rng = new StatefulRNG(CrossHash.hash64(name)); } /**
public Mist(final CharSequence alteration) { this(CrossHash.hash64(alteration), Lightning.hash64(alteration)); } private static int permute(final long state)
/** * Constructs a new Thesaurus, seeding its RNG (used to shuffle word order) with shuffleSeed. * @param shuffleSeed a String for seeding this class' RNG */ public Thesaurus(String shuffleSeed) { mappings = new OrderedMap<>(256, Hashers.caseInsensitiveStringHasher); this.rng = new GWTRNG(CrossHash.hash64(shuffleSeed)); }
@Override public int hashCode() { long result; result = CrossHash.hash64(replacer.getPattern().serializeToString()); result = 31L * result + NumberTools.doubleToLongBits(chance); result ^= result >>> 32; return (int) (0xFFFFFFFFL & result); }