the final solution to the randomness problem

This commit is contained in:
shweet 2024-08-29 22:16:35 -04:00
parent f63b445e52
commit a7cb9a7383
5 changed files with 8 additions and 4 deletions

View File

@ -24,6 +24,8 @@ void jsw_seed ( unsigned long s )
* ( x[i - 1] ^ ( x[i - 1] >> 30 ) ) + i ); * ( x[i - 1] ^ ( x[i - 1] >> 30 ) ) + i );
x[i] &= 0xffffffffUL; x[i] &= 0xffffffffUL;
} }
next = 0;
} }
/* Mersenne Twister */ /* Mersenne Twister */
@ -70,4 +72,4 @@ unsigned jsw_time_seed()
seed = seed * ( UCHAR_MAX + 2U ) + p[i]; seed = seed * ( UCHAR_MAX + 2U ) + p[i];
return seed; return seed;
} }

View File

@ -9,7 +9,7 @@ random_seed_set(u64 seed)
void void
random_seed_time_set(void) random_seed_time_set(void)
{ {
jsw_time_seed(); random_seed_set(jsw_time_seed());
} }
f32 f32

View File

@ -92,7 +92,7 @@ game_init(Game* self)
memset(self, '\0', sizeof(Game)); memset(self, '\0', sizeof(Game));
random_seed_time_set(); random_seed_set(0);
resource_shader_read(&self->resources); resource_shader_read(&self->resources);

View File

@ -227,6 +227,8 @@ level_init(Level* self, ECS* ecs, LevelSettings settings, u32 levelValue)
level_pause_init(self); level_pause_init(self);
level_unpause(self); level_unpause(self);
random_seed_set(0);
self->settings = settings; self->settings = settings;
self->medal = LEVEL_MEDAL_NONE; self->medal = LEVEL_MEDAL_NONE;
self->nextMedal = LEVEL_MEDAL_BRONZE; self->nextMedal = LEVEL_MEDAL_BRONZE;

View File

@ -396,7 +396,7 @@ static const LevelData LEVEL_DATA_DEFAULT[LEVEL_COUNT] =
.time = -1 .time = -1
}, },
{ {
.status = LEVEL_STATUS_UNLOCKED, .status = LEVEL_STATUS_LOCKED,
.score = -1, .score = -1,
.time = -1 .time = -1
}, },