Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts.lib RNG usage examples are not clear #450

Closed
5 tasks done
tukib opened this issue May 6, 2024 · 0 comments
Closed
5 tasks done

scripts.lib RNG usage examples are not clear #450

tukib opened this issue May 6, 2024 · 0 comments

Comments

@tukib
Copy link
Member

tukib commented May 6, 2024

Problem

The examples for the scripts.lib RNG methods do not show how to generate a random value.

Context

Affects:

LCG current:

function(context, args) {
  const l = #fs.scripts.lib();
  my_seed = 12345;

  return l.LCG(my_seed);
}

LCG example improvement:

function(context, args) {
  const l = #fs.scripts.lib();
  const seed = 12345;
  const rng = l.LCG(seed);
  const random_value = Math.floor(rng() * 10) // random value from 0 (inclusive) to 10 (exclusive)
  return random_value
}
@tukib tukib added the needs triage This is a new issue that needs to be reviewed. label May 6, 2024
@tukib tukib closed this as completed May 8, 2024
@tukib tukib removed the needs triage This is a new issue that needs to be reviewed. label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant