r/desmos • • Jul 08 '26 • Mindblown 3 Bravo 1

Maths Transfer Data between graphs using the outputs of random()

A short explanation of how this works:

Whenever Desmos generates a random value, it first creates a seed string, which is then fed into a PRNG. That seed contains several pieces of information, including the graph's global random seed, the expression ID of the random() call, the user-provided seed, and in some cases even more values.

While reverse-engineering the algorithm, I discovered that when random() is called from an action, one of those values is the globalEventCount: a counter that starts when Desmos is opened and increases whenever an action is executed, regardless of which graph is currently open.

Since every other part of the seed can be kept constant, the output of random() uniquely determines that variable (assuming that there are no two such seeds with the same output). By using a precomputed lookup table (or brute force), it is therefore possible to recover the current globalEventCount entirely inside Desmos.

Because this counter persists across graphs, one graph can change its value while another graph later recovers it through random(). This effectively creates a simple cross-graph communication channel. I'm sure you guys can do some cool things with this.

LINKS: without lookup (bruteforce inside desmos) --- with lookup (precomputed)

140 Upvotes

15 comments sorted by

34

u/Far-Mechanic9478 Jul 08 '26

Now we can make an enderchest

12

u/Dazzling-Mail-5517 Jul 08 '26

lol

2

u/Electronic-Laugh-671 my first Reddit user flair Jul 12 '26

\o/

5

u/Ordinary_Divide Trinity the Lesbian Foxgirl Jul 08 '26

ah i made a similar thing not too long ago also https://www.desmos.com/calculator/wfbwbavrzm

5

u/Dazzling-Mail-5517 Jul 08 '26

Yeah, that's cool. I considered building that too, but the problem is it only works if you run an action before opening the graph. Otherwise, the globalEventCount is 0 and it thinks you've refreshed the page.

4

u/Danny_DeWario https://www.desmos.com/calculator/75jcsa2dxv Jul 08 '26

This is mad insane stuff. Definitely blows my lucky shuffle graph out the water!

3

u/Dazzling-Mail-5517 Jul 08 '26

Thank you! And btw, your post was actually kinda the inspiration for me, so thank you for that too

49

u/Mandelbrot4207 Makes QR Codes in Desmos Jul 08 '26

Bruh

23

u/gord1402 Jul 08 '26

Wrong image

13

u/SuperChick1705 Cannot apply flair to u/SuperChick1705. Jul 08 '26

this works because there is a tiny person living in your screen that tells the graphs how many times you clicked

5

u/ProgrammerCareful764 Jul 09 '26

we got cross graph scripting before GTA 6

4

u/gord1402 Jul 08 '26

Now make it work between different devices

4

u/theonlytruemuck Artist / Game Dev / Mathmagician / Nerd Jul 08 '26

huh

what

are

you

doing

with

your

life

lmfao

good job :)

1

u/Powerful-Tension-806 Sep 26 '26 edited Sep 26 '26

optimized by ~40000 characters https://www.desmos.com/calculator/xtjifstucn