+ "NEXT-INT N => INT
+
+ARGUMENTS AND VALUES:
+
+ N: An integer representing the upper bound
+ INT: An integer
+
+DESCRIPTION:
+
+ NEXT-INTEGER returns the next randomly generated integer.
+
+ It does so in a way that's in accordance with java.util.Random and
+ the MerseinneTwisterFast that's in NetLogo. It also advances the
+ RNG and is bounded by N."
+ (if
+ (= n (logand n (- n) ))
+ (ash (* n (ash (mt19937:random-chunk mt19937:*random-state*) -1) ) -31)
+ (rem (ash (mt19937:random-chunk mt19937:*random-state*) -1) n)))