Function GetPrngNumber

From Uzebox Wiki
Jump to: navigation, search
Prototype

u16 GetPrngNumber(u16 seed);

Description

Obtain a pseudo random number based on a fast linear feedback shift register technique. If you supply a 0 as argument it will give you the next output of the sequence, otherwise you can set the seed value. This is deterministic(though not predictable to a casual player), but can be started at a truly random place in the repeating sequence by seeding it with GetTrueRandomSeed() after enabling -DTRUE_RANDOM_GEN=1 in your makefile.

Parameters

seed value, leave 0 to simply get the next iteration

Returns

The next output of a long and hard to predict equation(pseudo random).

Video Modes

N/A

Since

V3.3

Example:

int main(){
  GetPrngNumber(GetTrueRandomSeed());//seed it with a real random number
  ...

  int r=GetPrngNumber(0);//get a random value
  ...
  return 0;
}