Skip to content

[2.x] Add a way to get the value of the current random seed #7711

Open
@XenusYard

Description

@XenusYard

Increasing access

I believe this feature would increase the consistency of the API (i.e. you can both set and get the value of the current frame rate, for instance, but you can only set and never get the value of the random seed) and make iterative development centered around randomness easier and friendlier.

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

Feature request details

It is sometimes useful to know the value of the random seed that produced a specific result — be it for debugging or presentation purposes, or something else.

Currently the only way to know the seed value in advance is to generate it with random() first, save that value and pass it to randomSeed(). It is cumbersome and requires setting it up every time you want to keep track of your random seeds.

Without a similar setup reproducing a specific result may be a tedious and unreliable process — especially if the degree of accuracy required is very strict.

Thus, I propose adding a way of fetching the current value of the random seed, perhaps in a form of a variable (e.g. seed) or a function (e.g. getRandomSeed() or seed()). That way the value could be conveniently retrieved at any moment during runtime (for example, from the dev console in the browser) and referenced later.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions