pmd-sky/include/dg_random.h
2026-05-06 08:40:40 -04:00

34 lines
1.4 KiB
C

#ifndef PMDSKY_DG_RANDOM_H
#define PMDSKY_DG_RANDOM_H
#include "util.h"
typedef struct prng_state {
bool8 use_secondary;
u32 seq_num_primary;
u32 preseed;
u32 last_value_primary;
s32 idx_secondary;
} prng_state;
void InitDungeonRng(u32 seed);
u16 DungeonRand16Bit(void);
// Compute a pseudorandom integer under a given maximum value using the dungeon PRNG.
// pseudorandom integer on the interval [0, end - 1]
s32 DungeonRandInt(s32 end);
// Compute a pseudorandom value between two integers using the dungeon PRNG.
// If both input integers are the same, the first is returned.
// return: pseudorandom integer on the interval [min(from, to), max(from, to) - 1], or from if from == to.
s32 DungeonRandRange(s32 from, s32 to);
// Returns the result of a possibly biased coin flip (a Bernoulli random variable) with some success probability p, using the dungeon PRNG.
// percentChance: success percentage (100*p)
// return: true with probability p, false with probability (1-p)
bool8 DungeonRandOutcome__022EAB20(s32 percentChance);
// Returns the result of a possibly biased coin flip (a Bernoulli random variable) with some success probability p, using the dungeon PRNG.
// percentChance: success percentage (100*p)
// return: true with probability p, false with probability (1-p)
bool8 DungeonRandOutcome__022EAB50(s32 percentChance);
#endif //PMDSKY_DG_RANDOM_H