Skip to content

scripts.lib RNG usage examples are not clear #450

Closed
@tukib

Description

@tukib

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions