Skip to content

Commit

Permalink
Add CriticalRNG for super-luck, update others
Browse files Browse the repository at this point in the history
CriticalRNG should make some unusual cases easier to implement, where a
character can exceed the normal limits of what some ability can do by
sheer luck. It isn't a general RNG since it can and frequently will
produce values that are larger or smaller than an arrays's limits if
it's used to get a random element from an array as-is; instead it could
be used to get multiple items from that array if the value is very high,
or from a different array if it is high or low.

Various subclasses of RNG hadn't been looked at in a while; some methods
were marked GwtIncompatible but that no longer applied as of GWT 2.8.0,
while others could be made more general thanks to changes in APIs
elsewhere (String parameters were just passed to CrossHash, so they
could be CharSequence parameters and so take StringBuilders and such).
  • Loading branch information
tommyettinger committed Sep 21, 2017
1 parent c828120 commit 42b72c6
Show file tree
Hide file tree
Showing 58 changed files with 15,473 additions and 14,444 deletions.
1 change: 1 addition & 0 deletions docs/squidlib-util/allclasses-frame.html
Expand Up @@ -57,6 +57,7 @@ <h1 class="bar">All&nbsp;Classes</h1>
<li><a href="squidpony/tileset/CornerCaves.html" title="class in squidpony.tileset" target="classFrame">CornerCaves</a></li>
<li><a href="squidpony/squidmath/CosmicNumbering.html" title="class in squidpony.squidmath" target="classFrame">CosmicNumbering</a></li>
<li><a href="squidpony/squidgrid/mapping/locks/constraints/CountConstraints.html" title="class in squidpony.squidgrid.mapping.locks.constraints" target="classFrame">CountConstraints</a></li>
<li><a href="squidpony/squidmath/CriticalRNG.html" title="class in squidpony.squidmath" target="classFrame">CriticalRNG</a></li>
<li><a href="squidpony/squidmath/CrossHash.html" title="class in squidpony.squidmath" target="classFrame">CrossHash</a></li>
<li><a href="squidpony/squidmath/CrossHash.Falcon.html" title="class in squidpony.squidmath" target="classFrame">CrossHash.Falcon</a></li>
<li><a href="squidpony/squidmath/CrossHash.IHasher.html" title="interface in squidpony.squidmath" target="classFrame"><span class="interfaceName">CrossHash.IHasher</span></a></li>
Expand Down
1 change: 1 addition & 0 deletions docs/squidlib-util/allclasses-noframe.html
Expand Up @@ -57,6 +57,7 @@ <h1 class="bar">All&nbsp;Classes</h1>
<li><a href="squidpony/tileset/CornerCaves.html" title="class in squidpony.tileset">CornerCaves</a></li>
<li><a href="squidpony/squidmath/CosmicNumbering.html" title="class in squidpony.squidmath">CosmicNumbering</a></li>
<li><a href="squidpony/squidgrid/mapping/locks/constraints/CountConstraints.html" title="class in squidpony.squidgrid.mapping.locks.constraints">CountConstraints</a></li>
<li><a href="squidpony/squidmath/CriticalRNG.html" title="class in squidpony.squidmath">CriticalRNG</a></li>
<li><a href="squidpony/squidmath/CrossHash.html" title="class in squidpony.squidmath">CrossHash</a></li>
<li><a href="squidpony/squidmath/CrossHash.Falcon.html" title="class in squidpony.squidmath">CrossHash.Falcon</a></li>
<li><a href="squidpony/squidmath/CrossHash.IHasher.html" title="interface in squidpony.squidmath"><span class="interfaceName">CrossHash.IHasher</span></a></li>
Expand Down
14 changes: 7 additions & 7 deletions docs/squidlib-util/constant-values.html

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion docs/squidlib-util/index-files/index-13.html
Expand Up @@ -723,7 +723,7 @@ <h2 class="title">L</h2>
<dd>
<div class="block">Identical to <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Double.html?is-external=true#longBitsToDouble-long-" title="class or interface in java.lang"><code>Double.longBitsToDouble(long)</code></a> on desktop; optimized on GWT.</div>
</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/MeadNoise.html#longFloor-float-">longFloor(float)</a></span> - Static method in class squidpony.squidmath.<a href="../squidpony/squidmath/MeadNoise.html" title="class in squidpony.squidmath">MeadNoise</a></dt>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/MeadNoise.html#longFloor-double-">longFloor(double)</a></span> - Static method in class squidpony.squidmath.<a href="../squidpony/squidmath/MeadNoise.html" title="class in squidpony.squidmath">MeadNoise</a></dt>
<dd>
<div class="block">Like <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html?is-external=true#floor-double-" title="class or interface in java.lang"><code>Math.floor(double)</code></a>, but returns an int.</div>
</dd>
Expand Down Expand Up @@ -845,6 +845,10 @@ <h2 class="title">L</h2>
<dd>
<div class="block">The LightRNG used as a RandomnessSource for the RNG this object uses.</div>
</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/CriticalRNG.html#luck">luck</a></span> - Variable in class squidpony.squidmath.<a href="../squidpony/squidmath/CriticalRNG.html" title="class in squidpony.squidmath">CriticalRNG</a></dt>
<dd>
<div class="block">Positive for higher results, negative for lower results; usually this is small, between -0.5f and 0.5f .</div>
</dd>
</dl>
<a href="index-1.html">$</a>&nbsp;<a href="index-2.html">A</a>&nbsp;<a href="index-3.html">B</a>&nbsp;<a href="index-4.html">C</a>&nbsp;<a href="index-5.html">D</a>&nbsp;<a href="index-6.html">E</a>&nbsp;<a href="index-7.html">F</a>&nbsp;<a href="index-8.html">G</a>&nbsp;<a href="index-9.html">H</a>&nbsp;<a href="index-10.html">I</a>&nbsp;<a href="index-11.html">J</a>&nbsp;<a href="index-12.html">K</a>&nbsp;<a href="index-13.html">L</a>&nbsp;<a href="index-14.html">M</a>&nbsp;<a href="index-15.html">N</a>&nbsp;<a href="index-16.html">O</a>&nbsp;<a href="index-17.html">P</a>&nbsp;<a href="index-18.html">Q</a>&nbsp;<a href="index-19.html">R</a>&nbsp;<a href="index-20.html">S</a>&nbsp;<a href="index-21.html">T</a>&nbsp;<a href="index-22.html">U</a>&nbsp;<a href="index-23.html">V</a>&nbsp;<a href="index-24.html">W</a>&nbsp;<a href="index-25.html">X</a>&nbsp;<a href="index-26.html">Y</a>&nbsp;<a href="index-27.html">Z</a>&nbsp;</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
Expand Down
22 changes: 20 additions & 2 deletions docs/squidlib-util/index-files/index-15.html
Expand Up @@ -401,6 +401,8 @@ <h2 class="title">N</h2>
<dd>
<div class="block">Generates and returns a block of 256 pseudo-random long values.</div>
</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/CriticalRNG.html#nextBoolean--">nextBoolean()</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/CriticalRNG.html" title="class in squidpony.squidmath">CriticalRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/DeckRNG.html#nextBoolean--">nextBoolean()</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/DeckRNG.html" title="class in squidpony.squidmath">DeckRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/DharmaRNG.html#nextBoolean--">nextBoolean()</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/DharmaRNG.html" title="class in squidpony.squidmath">DharmaRNG</a></dt>
Expand Down Expand Up @@ -495,6 +497,10 @@ <h2 class="title">N</h2>
<dd>
<div class="block">Generate a random vector.</div>
</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/CriticalRNG.html#nextDouble--">nextDouble()</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/CriticalRNG.html" title="class in squidpony.squidmath">CriticalRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/CriticalRNG.html#nextDouble-double-">nextDouble(double)</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/CriticalRNG.html" title="class in squidpony.squidmath">CriticalRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/DeckRNG.html#nextDouble--">nextDouble()</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/DeckRNG.html" title="class in squidpony.squidmath">DeckRNG</a></dt>
<dd>
<div class="block">Generate a random double, altering the result if recently generated results have been leaning
Expand Down Expand Up @@ -597,6 +603,8 @@ <h2 class="title">N</h2>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/XorRNG.html#nextDouble--">nextDouble()</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/XorRNG.html" title="class in squidpony.squidmath">XorRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/CriticalRNG.html#nextFloat--">nextFloat()</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/CriticalRNG.html" title="class in squidpony.squidmath">CriticalRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/DeckRNG.html#nextFloat--">nextFloat()</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/DeckRNG.html" title="class in squidpony.squidmath">DeckRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/DharmaRNG.html#nextFloat--">nextFloat()</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/DharmaRNG.html" title="class in squidpony.squidmath">DharmaRNG</a></dt>
Expand Down Expand Up @@ -642,6 +650,8 @@ <h2 class="title">N</h2>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/XorRNG.html#nextFloat--">nextFloat()</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/XorRNG.html" title="class in squidpony.squidmath">XorRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/CriticalRNG.html#nextGaussian--">nextGaussian()</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/CriticalRNG.html" title="class in squidpony.squidmath">CriticalRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/DeckRNG.html#nextGaussian--">nextGaussian()</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/DeckRNG.html" title="class in squidpony.squidmath">DeckRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/DharmaRNG.html#nextGaussian--">nextGaussian()</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/DharmaRNG.html" title="class in squidpony.squidmath">DharmaRNG</a></dt>
Expand All @@ -658,6 +668,10 @@ <h2 class="title">N</h2>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/BirdRNG.html#nextInt--">nextInt()</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/BirdRNG.html" title="class in squidpony.squidmath">BirdRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/CriticalRNG.html#nextInt-int-">nextInt(int)</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/CriticalRNG.html" title="class in squidpony.squidmath">CriticalRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/CriticalRNG.html#nextInt--">nextInt()</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/CriticalRNG.html" title="class in squidpony.squidmath">CriticalRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/DeckRNG.html#nextInt-int-">nextInt(int)</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/DeckRNG.html" title="class in squidpony.squidmath">DeckRNG</a></dt>
<dd>
<div class="block">Returns a random integer below the given bound, or 0 if the bound is 0 or
Expand Down Expand Up @@ -826,6 +840,8 @@ <h2 class="title">N</h2>
<div class="block">Gets a pseudo-random int, which can be positive or negative but is likely to be drawn from less possible options
than the full range of <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html?is-external=true#MIN_VALUE" title="class or interface in java.lang"><code>Integer.MIN_VALUE</code></a> to <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html?is-external=true#MAX_VALUE" title="class or interface in java.lang"><code>Integer.MAX_VALUE</code></a>.</div>
</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/CriticalRNG.html#nextIntHasty-int-">nextIntHasty(int)</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/CriticalRNG.html" title="class in squidpony.squidmath">CriticalRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/DeckRNG.html#nextIntHasty-int-">nextIntHasty(int)</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/DeckRNG.html" title="class in squidpony.squidmath">DeckRNG</a></dt>
<dd>
<div class="block">Returns a random non-negative integer below the given bound, or 0 if the bound is 0.</div>
Expand Down Expand Up @@ -860,6 +876,10 @@ <h2 class="title">N</h2>
<dd>
<div class="block">Can return any long, positive or negative, of any size permissible in a 64-bit signed integer.</div>
</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/CriticalRNG.html#nextLong--">nextLong()</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/CriticalRNG.html" title="class in squidpony.squidmath">CriticalRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/CriticalRNG.html#nextLong-long-">nextLong(long)</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/CriticalRNG.html" title="class in squidpony.squidmath">CriticalRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/DeckRNG.html#nextLong--">nextLong()</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/DeckRNG.html" title="class in squidpony.squidmath">DeckRNG</a></dt>
<dd>
<div class="block">Returns a random long, which may be positive or negative.</div>
Expand Down Expand Up @@ -1099,8 +1119,6 @@ <h2 class="title">N</h2>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/MeadNoise.html#noise-double-double-int-">noise(double, double, int)</a></span> - Static method in class squidpony.squidmath.<a href="../squidpony/squidmath/MeadNoise.html" title="class in squidpony.squidmath">MeadNoise</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/MeadNoise.html#noise-float-float-int-">noise(float, float, int)</a></span> - Static method in class squidpony.squidmath.<a href="../squidpony/squidmath/MeadNoise.html" title="class in squidpony.squidmath">MeadNoise</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/MeadNoise.html#noise-double-double-double-int-">noise(double, double, double, int)</a></span> - Static method in class squidpony.squidmath.<a href="../squidpony/squidmath/MeadNoise.html" title="class in squidpony.squidmath">MeadNoise</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/MeadNoise.html#noise-float-float-float-int-">noise(float, float, float, int)</a></span> - Static method in class squidpony.squidmath.<a href="../squidpony/squidmath/MeadNoise.html" title="class in squidpony.squidmath">MeadNoise</a></dt>
Expand Down
2 changes: 2 additions & 0 deletions docs/squidlib-util/index-files/index-18.html
Expand Up @@ -106,6 +106,8 @@ <h2 class="title">Q</h2>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/MeadNoise.html#querp-float-float-float-">querp(float, float, float)</a></span> - Static method in class squidpony.squidmath.<a href="../squidpony/squidmath/MeadNoise.html" title="class in squidpony.squidmath">MeadNoise</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/MeadNoise.html#querp-double-double-double-">querp(double, double, double)</a></span> - Static method in class squidpony.squidmath.<a href="../squidpony/squidmath/MeadNoise.html" title="class in squidpony.squidmath">MeadNoise</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/TabbyNoise.html#querp-double-double-double-">querp(double, double, double)</a></span> - Static method in class squidpony.squidmath.<a href="../squidpony/squidmath/TabbyNoise.html" title="class in squidpony.squidmath">TabbyNoise</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidgrid/FOVCache.html#queryCache-int-int-int-int-int-">queryCache(int, int, int, int, int)</a></span> - Method in class squidpony.squidgrid.<a href="../squidpony/squidgrid/FOVCache.html" title="class in squidpony.squidgrid">FOVCache</a></dt>
Expand Down
16 changes: 1 addition & 15 deletions docs/squidlib-util/index-files/index-19.html
Expand Up @@ -368,14 +368,6 @@ <h2 class="title">R</h2>
<dd>
<div class="block">Generates a random permutation of the range from 0 (inclusive) to length (exclusive).</div>
</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/DharmaRNG.html#randomOrdering-int-">randomOrdering(int)</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/DharmaRNG.html" title="class in squidpony.squidmath">DharmaRNG</a></dt>
<dd>
<div class="block">Generates a random permutation of the range from 0 (inclusive) to length (exclusive).</div>
</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/EditRNG.html#randomOrdering-int-">randomOrdering(int)</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/EditRNG.html" title="class in squidpony.squidmath">EditRNG</a></dt>
<dd>
<div class="block">Generates a random permutation of the range from 0 (inclusive) to length (exclusive).</div>
</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/RNG.html#randomOrdering-int-">randomOrdering(int)</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/RNG.html" title="class in squidpony.squidmath">RNG</a></dt>
<dd>
<div class="block">Generates a random permutation of the range from 0 (inclusive) to length (exclusive).</div>
Expand Down Expand Up @@ -452,12 +444,6 @@ <h2 class="title">R</h2>
</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/GreasedRegion.html#randomRegion-squidpony.squidmath.RNG-int-">randomRegion(RNG, int)</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/GreasedRegion.html" title="class in squidpony.squidmath">GreasedRegion</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/DeckRNG.html#randomRotation-java.util.List-">randomRotation(List&lt;T&gt;)</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/DeckRNG.html" title="class in squidpony.squidmath">DeckRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/DharmaRNG.html#randomRotation-java.util.List-">randomRotation(List&lt;T&gt;)</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/DharmaRNG.html" title="class in squidpony.squidmath">DharmaRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/EditRNG.html#randomRotation-java.util.List-">randomRotation(List&lt;T&gt;)</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/EditRNG.html" title="class in squidpony.squidmath">EditRNG</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/RNG.html#randomRotation-java.util.List-">randomRotation(List&lt;T&gt;)</a></span> - Method in class squidpony.squidmath.<a href="../squidpony/squidmath/RNG.html" title="class in squidpony.squidmath">RNG</a></dt>
<dd>
<div class="block">Given a <a href="http://docs.oracle.com/javase/7/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util"><code>List</code></a> l, this selects a random element of l to be the first value in the returned list l2.</div>
Expand Down Expand Up @@ -1978,7 +1964,7 @@ <h2 class="title">R</h2>
<div class="block">Seeded constructor; uses LightRNG, which is of high quality, but low period (which rarely matters for games),
and has good speed, tiny state size, and excellent 64-bit number generation.</div>
</dd>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/RNG.html#RNG-java.lang.String-">RNG(String)</a></span> - Constructor for class squidpony.squidmath.<a href="../squidpony/squidmath/RNG.html" title="class in squidpony.squidmath">RNG</a></dt>
<dt><span class="memberNameLink"><a href="../squidpony/squidmath/RNG.html#RNG-java.lang.CharSequence-">RNG(CharSequence)</a></span> - Constructor for class squidpony.squidmath.<a href="../squidpony/squidmath/RNG.html" title="class in squidpony.squidmath">RNG</a></dt>
<dd>
<div class="block">String-seeded constructor; uses a platform-independent hash of the String (it does not use String.hashCode) as a
seed for LightRNG, which is of high quality, but low period (which rarely matters for games), and has good speed,
Expand Down

0 comments on commit 42b72c6

Please sign in to comment.