Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

On pseudorandom numbers and Tetris

Name: Anonymous 2009-11-15 11:24

So I'm programming a Tetris clone in Sepples and SDL. I need a method of generating a random number between 0 and 6 (seven different types of blocks) that gives a, more or less, even chance for each value to occur. I could use ctime and cstdlib to generate a pseudorandom number, then modulus that number by 7, but that wouldn't be an even chance. Some pieces would fall more often than others.

How does /prog/ get their pseudorandoms to be convincing?

Name: !Xarn.T4glk 2009-11-16 3:08

>>27
I'm in!

Name: Anonymous 2009-11-16 3:20

>>40
Yawn. Close enough. This isn't fuckin' crypto.

Name: Anonymous 2009-11-16 8:35

>>40
But it's not.  There are 306783379 ways to pick (each of) 0 or 1, but only 306783378 ways to pick 2 through 6.

Name: ​​​​​​​​​​ 2010-10-24 3:09

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List