Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6be9b4a
commit f57326d
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class CiaccoRandom | ||
{ | ||
|
||
private static int superSeed = 0; | ||
|
||
public CiaccoRandom() | ||
{ | ||
|
||
} | ||
|
||
public void setSeed(int seed) | ||
{ | ||
// seed can only be positive and seed range is [0 -> 9999998] seed=9999999 schould give the same as seed=0 | ||
superSeed = Mathf.Abs(seed) % 9999999 + 1; | ||
// init for randomness fairness | ||
superSeed = (superSeed * 125) % 2796203; | ||
superSeed = (superSeed * 125) % 2796203; | ||
superSeed = (superSeed * 125) % 2796203; | ||
superSeed = (superSeed * 125) % 2796203; | ||
superSeed = (superSeed * 125) % 2796203; | ||
superSeed = (superSeed * 125) % 2796203; | ||
superSeed = (superSeed * 125) % 2796203; | ||
superSeed = (superSeed * 125) % 2796203; | ||
superSeed = (superSeed * 125) % 2796203; | ||
} | ||
|
||
public int getRand(int min, int max) // both included: getRand(0,1) will return 0s and 1s | ||
{ | ||
superSeed = (superSeed * 125) % 2796203; | ||
return superSeed % (max - min + 1) + min; | ||
} | ||
} |