cambridge/tetris/randomizers/bag7noSZOstart.lua
Oshisaure 1366451a3d Fixed randomisers in A1-A4 modes:
- History 4-rolls, history 6-rolls and history 6-rolls 35-bag no longer deal S, Z or O as their first piece
- Added a 7-bag randomiser with the same behaviour (bag7noSZOstart)
- Tweaked the "35-bag" part of the history 6-rolls 35-bag randomiser to work closer to what it's supposed to be
- Switched Marathon AX4's randomiser from history 6-rolls to 7-bag no SZO start
2020-10-09 04:34:11 +01:00

32 lines
774 B
Lua

local Randomizer = require 'tetris.randomizers.randomizer'
local Bag7NoSZOStartRandomizer = Randomizer:extend()
function Bag7NoSZOStartRandomizer:shuffleBag()
local b = self.bag
local ln = #b
for i = 1, ln do
local j = math.random(i, ln)
b[i], b[j] = b[j], b[i]
end
end
local function isnotSZO(x) return not(x == "S" or x == "Z" or x == "O") end
function Bag7NoSZOStartRandomizer:initialize()
self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
repeat
self:shuffleBag()
until isnotSZO(self.bag[7])
end
function Bag7NoSZOStartRandomizer:generatePiece()
if #self.bag == 0 then
self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
self:shuffleBag()
end
return table.remove(self.bag)
end
return Bag7NoSZOStartRandomizer