LonamiWebs/Klooni1010

None of the set of three pieces matches

StefanBrand opened this issue · 5 comments

I recently had the following situation:

screenshot_2017-02-16-08-37-14

Immediately after the new set of three appeared, the game was lost because none fit. Could you implement a check so that at least one of the tiles matches?

Could you implement a check so that at least one of the tiles matches?

Nope, it's chance, you might as well die because of bad chance. But I will sure fix it so it shows "Game over". Thanks.

Oh, it showed "Game over", I just went back to the game screen!

Good to know I planned everything beforehand lol! 😁

Something didn't seem right in your implementation of the piece generation algorithm, so I decompiled the code for the original 1010! game, and it turns out that the piece spawning isn't completely random after all - certain pieces are weighted more than others.

Basically, each piece has a weight attached to it. When generating each piece, the game generates a random number between 0 and the sum of all the pieces' weights. Then, the game loops through the list of possible pieces (apparently sorted in no particular order - I'd think that this would affect the probabilities? 5x1 pieces are first and 3x3 piece is last), subtracting each piece's weight from the random number until the number is less than the next piece's weight.

To not contaminate your code with copyrighted decompiled code, I am not going to commit anything myself. However, I extracted the piece weights from the original game, which I do not believe can be covered under copyright. Here is a gist with a list of ASCII pieces categorized by weight.

I'd recommend you not take the piece weights from the original game and experiment with this yourself. IMO the only piece that really needs to be weighted badly is the 3x3 piece. If you change this, maybe you could add a (possibly "hidden") option to change between fair and weighted randoms to the game?

Heh thank you for your effort of looking how this is made, but I'm not sure it's really necessary? I think I saw some people complaining on the original game about pieces "being random" and it being unfair. Not sure if this was the way to fix it, or if it still feels random and "unplayable" in a "fair" way (after all, it's still random, you can have a good or a bad game).

Anyway, despite having the original weights, perhaps the weights could simply be how "hard" it is to put a piece (the 3x3 L and 5x1 are hard in my opinion), and the hard ones are less likely to be chosen. But I'm not sure if it's worth. Would it actually be noticeable since it would still be random? Sure, some pieces would occur more often… Not sure.