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: Anonymous 2009-11-15 13:03

>>7
// produce integers in the range [0, limit).
Wrong.  It will be 0 through limit-1.

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