|Tom Kerrigan's Home Page|
I found out that some work has gone into "Tetris randomizers," i.e., the algorithms that choose which Tetris piece you get next.
Simon Laroche wrote an interesting post on the subject:
The idea is that you want the pieces to be random, but in such a way that you avoid floods (getting the same piece over and over) and droughts (not getting a particular piece for a long time).
I think I've come up with a pretty good way to do this.
It becomes obvious if you state the problem like this:
This algorithm seems to perform well in my simulations.
An advantage of the algorithm is that it can be tuned by changing the initial value of pieceProb[1 ... 7]. A value of 1 will result in optimal flood and drought avoidance but also be very predictable. A value of a million will make it almost perfectly random. I think a value of 10 is a good place to start but I'm not a Tetris expert.
I'm making this algorithm public domain. If you want to use it, I would appreciate an email at firstname.lastname@example.org.