# Generate seed while runtime

**URL:** <https://discourse.processing.org/t/generate-seed-while-runtime/33736>\
**Category:** Coding Questions\
**Created:** [November 25, 2021, 1:25am UTC](https://discourse.processing.org/t/generate-seed-while-runtime/33736 "2021-11-25T01:25:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![res56](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@res56](https://discourse.processing.org/u/res56)\
**Post date:** [November 25, 2021, 1:25am UTC](https://discourse.processing.org/t/generate-seed-while-runtime/33736/1 "2021-11-25T01:25:23Z")

</div>

Hey guys,

how can I create a unique seed while run time to save the script with this seed and use it for random functions. The goal is to have an instance of the script that returns the same result while using random function (random function generates values by using this seed).

Thanks in advance

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [November 25, 2021, 8:16pm UTC](https://discourse.processing.org/t/generate-seed-while-runtime/33736/2 "2021-11-25T20:16:37Z")

</div>

maybe randomSeed();

> **[Reference](https://processing.org/reference/randomSeed_.html)**
>
> Sets the seed value for random(). By default, random() produces different results each time the program is run. Set the seed parameter to a constant to return the same pseudo-rand…

but be careful because:

```auto
randomSeed(5);
randomSeed((int)random(10));
println(random(100));

```

it always returns 73.0699 for me. It can be useful if you use it correctly, but still be aware of this. If you want to exit this loop of constant random values, just use something like:  
`randomSeed(millis());` or frame count, mouseX, day(), second(), hour(), or a sombination of them all.
