Discuss Scratch

-ByDesign-
Scratcher
4 posts

Help with calculating PI

I'm making a Wave Function Collapse test project and I want a seed system implemented. The easiest way I know how to do it is using PI for the random numbers. Does anyone know how to calculate PI in Scratch?

Last edited by -ByDesign- (Oct. 15, 2025 18:57:08)

kahyreedre
Scratcher
37 posts

Help with calculating PI

I I don't know if you can calculate the pi but there is a chance that you can just type the first like 10 letters of pi and it will work the same, also there is a random number operator
1234not123abc
Scratcher
100+ posts

Help with calculating PI

Lpea42
Scratcher
100+ posts

Help with calculating PI

Start with 1
Take away 1 divided by 3 (that’s like making a little mistake correction)
Add 1 divided by 5
Take away 1 divided by 7
Add 1 divided by 9, and so on forever

Why it works: Every time you add or subtract the next fraction, you get a number a little closer to the real value of π. It’s like getting closer to a treasure by taking steps forward and backward, each step smaller than the last.
A quick example with the first few steps:
Start: 1 → multiply by 4 → 4 (way too high)
Next step: 1 - 1/3 = 2/3 → multiply by 4 → 2.666… (now too low)
Next step: 2/3 + 1/5 = 13/15 → multiply by 4 → ≈3.466… (closer!)
Next step: 13/15 - 1/7 ≈ 2.623… → multiply by 4 → ≈3.747…
If you keep going, the numbers bounce closer and closer to 3.14159.
N8_D_GR8_1
Scratcher
1000+ posts

Help with calculating PI

With the limitations of Scratch's math operations, having an approximation with 16 digits is as much as you can do. Any more precision will be ignored by Scratch.
-ByDesign-
Scratcher
4 posts

Help with calculating PI

Thanks for the help! I ended up just copying the first 50 digits of PI into a variable, removing the “.” entirely.

Last edited by -ByDesign- (Oct. 17, 2025 18:22:47)

Powered by DjangoBB