Comment by bubblesorting
9 hours ago
I enjoyed playing Linex! It reminds me of doing perfect clear solves in Tetris, but without the stress :) I appreciate the skip, next, and hole-fill power ups.
If you don't mind me asking, how are you doing piece generation? Is it random%7, drawing from a bag, or something else?
It's neither purely random 7 nor like drawing from a bag. It's a little bit more complex.
If I were to explain it the technical way: I use a custom Linear Congruential Generator (LCG) seeded by the current date (YYYYMMDD) to ensure deterministic gameplay—everyone gets the exact same piece sequence every day. I don't use flat probabilities; instead, I run the LCG output through a weighted roulette that changes based on the day of the week (e.g., higher probability for 'I' pieces on Mondays, higher for 'S' and 'Z' pieces on Sundays). Lastly, there's a system to mitigate consecutive identical pieces.
In simpler terms: I use a formula based on the current date to generate a different sequence of pieces every day, guaranteeing it's exactly the same for all users on that specific day. Then, I adjust this sequence using a probability matrix so that on Mondays you get more of the easy pieces (like the line or square), and on Sundays you get more of the hard ones (like S or Z).
This is the probability matrix:
const pieceProbabilities = { 1: [0.20, 0.18, 0.16, 0.14, 0.14, 0.09, 0.09], // Monday 2: [0.18, 0.17, 0.15, 0.14, 0.14, 0.11, 0.11], // Tuesday 3: [0.16, 0.15, 0.15, 0.14, 0.14, 0.13, 0.13], // Wednesday 4: [0.14, 0.14, 0.14, 0.14, 0.14, 0.15, 0.15], // Thursday 5: [0.12, 0.12, 0.12, 0.15, 0.15, 0.17, 0.17], // Friday 6: [0.10, 0.12, 0.12, 0.15, 0.15, 0.18, 0.18], // Saturday 7: [0.09, 0.10, 0.13, 0.15, 0.15, 0.19, 0.19] // Sunday };
I hope this explains it well!
Extremely cool! I have never seen that type of piece randomizer, thanks for sharing