Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Random expression without repeating

New Here ,
Jul 18, 2021 Jul 18, 2021

I was looking for a solution to a problem. When I apply this expression

i = Math.round(random(1, 3)

It chooses a sequence of numbers with repetitions.. like...

1, 3, 2, 2, 2, 3, 1, 3, 3...

 

I'd like to know if there's a way to do the same thing without repeating numbers.

 

thanks!

TOPICS
Expressions
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 18, 2021 Jul 18, 2021

Try this solution here - https://creativecow.net/forums/thread/how-to-make-random-generator-not-repeat-twice-the/

Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 19, 2021 Jul 19, 2021
LATEST

No need for complicated workarounds. Just increase the spread of the random range like e.g. from 1 to 300 and then scale the values with multiplications/ divisions or remap the ranges using linear(). Also random() accepts arrays, something which most people are completely ignorant of, so a simple random([1,2,3,2,3,1]) and so on can greatly improve distribution. In fact you could then even include a relatively trivial if()else{} check to prevent values on subsequent frames to be identical.

 

Mylenium

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines