Document magic value in Tetra-X randomizer

pull/3/head
nathyong 2020-12-03 12:56:02 +11:00
parent 52ee433e7f
commit a4c6509222
1 changed files with 1 additions and 0 deletions

View File

@ -58,6 +58,7 @@ function TetraXRandomizer:generatePiece()
-- shuffle the piece selection for the next time -- shuffle the piece selection for the next time
self.pieceselection = {} self.pieceselection = {}
for piece, count in pairs(self.count) do for piece, count in pairs(self.count) do
-- in this case 6 = #piece types - 1, so all probabilities sum to 1
local probability = (self.totalcount - count) / (self.totalcount * 6) local probability = (self.totalcount - count) / (self.totalcount * 6)
local chances = math.floor(probability * 1000 + 0.5) -- simulated "round" local chances = math.floor(probability * 1000 + 0.5) -- simulated "round"
for _ = 1, chances do for _ = 1, chances do