processing / processing/p5.js

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

Open
#7,711 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area:Math Discussion Feature Request
Dominant language
JavaScript
Stars
24k
Forks
3.8k
Avg merge
3d 16h
Merged PRs (30d)
25

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests; start by locating the existing random() and randomSeed() API entry points in p5.js. Review how related state such as frame rate is exposed, then determine the getter's intended semantics and add coverage showing that the current seed can be retrieved reliably.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.