diff options
| author | citrons <citrons@mondecitronne.com> | 2023-10-14 00:20:50 -0500 |
|---|---|---|
| committer | citrons <citrons@mondecitronne.com> | 2023-10-14 00:20:50 -0500 |
| commit | 0928b5cbbde02d4a6c58ca940040ae4a1c2ac2e4 (patch) | |
| tree | c5725ba5dc07a810ed1e0e743658a1fd0d2c6e20 /random.c | |
| parent | 55ea3a406e7232dc5848101dd806819e59df4cac (diff) | |
give the terrain a texture
Diffstat (limited to 'random.c')
| -rw-r--r-- | random.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -2,14 +2,25 @@ static Uint64 random = 0xbee; +Uint64 hash(Uint64 n) { + Uint64 h = 0; + for (int i = 0; i < 8; i++) { + h += (n >> i * 8) & 0xFF; + h += h << 10; + h ^= h >> 6; + } + h += h << 3; + h ^= h >> 11; + h += h << 15; + return h; +} + void seed_rand(Uint64 seed) { random ^= seed; } Uint64 get_rand() { - random ^= random >> 7; - random ^= random << 9; - random ^= random >> 13; + random = hash(random); return random; } |
