From f1528e8d71b3e10e36c1a444f1620317ae4655da Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Thu, 28 Jan 2021 21:05:36 -0500 Subject: [PATCH] Fixed the SRS variants from latest commit. --- tetris/rulesets/standard.lua | 186 +------------------------------ tetris/rulesets/standard_exp.lua | 6 +- 2 files changed, 5 insertions(+), 187 deletions(-) diff --git a/tetris/rulesets/standard.lua b/tetris/rulesets/standard.lua index 601f614..88d848b 100644 --- a/tetris/rulesets/standard.lua +++ b/tetris/rulesets/standard.lua @@ -5,199 +5,17 @@ local SRS = Ruleset:extend() SRS.name = "Guideline SRS" SRS.hash = "Standard" -SRS.world = true -SRS.colourscheme = { - I = "C", - L = "O", - J = "B", - S = "G", - Z = "R", - O = "Y", - T = "M", -} SRS.softdrop_lock = false SRS.harddrop_lock = true -SRS.enable_IRS_wallkicks = true - -SRS.spawn_positions = { - I = { x=5, y=2 }, - J = { x=4, y=3 }, - L = { x=4, y=3 }, - O = { x=5, y=3 }, - S = { x=4, y=3 }, - T = { x=4, y=3 }, - Z = { x=4, y=3 }, -} - -SRS.big_spawn_positions = { - I = { x=3, y=0 }, - J = { x=2, y=1 }, - L = { x=2, y=1 }, - O = { x=3, y=1 }, - S = { x=2, y=1 }, - T = { x=2, y=1 }, - Z = { x=2, y=1 }, -} - -SRS.block_offsets = { - I={ - { {x=0, y=0}, {x=-1, y=0}, {x=-2, y=0}, {x=1, y=0} }, - { {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=0, y=2} }, - { {x=0, y=1}, {x=-1, y=1}, {x=-2, y=1}, {x=1, y=1} }, - { {x=-1, y=0}, {x=-1, y=-1}, {x=-1, y=1}, {x=-1, y=2} }, - }, - J={ - { {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=-1, y=-1} }, - { {x=0, y=0}, {x=0, y=-1}, {x=0, y=1} , {x=1, y=-1} }, - { {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=1, y=1} }, - { {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=1} }, - }, - L={ - { {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=1, y=-1} }, - { {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=1, y=1} }, - { {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=-1, y=1} }, - { {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=-1} }, - }, - O={ - { {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} }, - { {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} }, - { {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} }, - { {x=0, y=0}, {x=-1, y=0}, {x=-1, y=-1}, {x=0, y=-1} }, - }, - S={ - { {x=1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=-1, y=0} }, - { {x=1, y=1}, {x=1, y=0}, {x=0, y=0}, {x=0, y=-1} }, - { {x=-1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=1, y=0} }, - { {x=-1, y=-1}, {x=-1, y=0}, {x=0, y=0}, {x=0, y=1} }, - }, - T={ - { {x=0, y=0}, {x=-1, y=0}, {x=1, y=0}, {x=0, y=-1} }, - { {x=0, y=0}, {x=0, y=-1}, {x=0, y=1}, {x=1, y=0} }, - { {x=0, y=0}, {x=1, y=0}, {x=-1, y=0}, {x=0, y=1} }, - { {x=0, y=0}, {x=0, y=1}, {x=0, y=-1}, {x=-1, y=0} }, - }, - Z={ - { {x=-1, y=-1}, {x=0, y=-1}, {x=0, y=0}, {x=1, y=0} }, - { {x=1, y=-1}, {x=1, y=0}, {x=0, y=0}, {x=0, y=1} }, - { {x=1, y=1}, {x=0, y=1}, {x=0, y=0}, {x=-1, y=0} }, - { {x=-1, y=1}, {x=-1, y=0}, {x=0, y=0}, {x=0, y=-1} }, - } -} - -SRS.wallkicks_3x3 = { - [0]={ - [1]={{x=-1, y=0}, {x=-1, y=-1}, {x=0, y=2}, {x=-1, y=2}}, - [2]={{x=0, y=1}, {x=0, y=-1}}, - [3]={{x=1, y=0}, {x=1, y=-1}, {x=0, y=2}, {x=1, y=2}}, - }, - [1]={ - [0]={{x=1, y=0}, {x=1, y=1}, {x=0, y=-2}, {x=1, y=-2}}, - [2]={{x=1, y=0}, {x=1, y=1}, {x=0, y=-2}, {x=1, y=-2}}, - [3]={{x=0, y=1}, {x=0, y=-1}}, - }, - [2]={ - [0]={{x=0, y=1}, {x=0, y=-1}}, - [1]={{x=-1, y=0}, {x=-1, y=-1}, {x=0, y=2}, {x=-1, y=2}}, - [3]={{x=1, y=0}, {x=1, y=-1}, {x=0, y=2}, {x=1, y=2}}, - }, - [3]={ - [0]={{x=-1, y=0}, {x=-1, y=1}, {x=0, y=-2}, {x=-1, y=-2}}, - [1]={{x=0, y=1}, {x=0, y=-1}}, - [2]={{x=-1, y=0}, {x=-1, y=1}, {x=0, y=-2}, {x=-1, y=-2}}, - }, -}; - -SRS.wallkicks_line = { - [0]={ - [1]={{x=-2, y=0}, {x=1, y=0}, {x=-2, y=1}, {x=1, y=-2}}, - [2]={}, - [3]={{x=-1, y=0}, {x=2, y=0}, {x=-1, y=-2}, {x=2, y=1}}, - }, - [1]={ - [0]={{x=2, y=0}, {x=-1, y=0}, {x=2, y=-1}, {x=-1, y=2}}, - [2]={{x=-1, y=0}, {x=2, y=0}, {x=-1, y=-2}, {x=2, y=1}}, - [3]={{x=0, y=1}, {x=0, y=-1}, {x=0, y=2}, {x=0, y=-2}}, - }, - [2]={ - [0]={}, - [1]={{x=1, y=0}, {x=-2, y=0}, {x=1, y=2}, {x=-2, y=-1}}, - [3]={{x=2, y=0}, {x=-1, y=0}, {x=2, y=-1}, {x=-1, y=2}}, - }, - [3]={ - [0]={{x=1, y=0}, {x=-2, y=0}, {x=1, y=2}, {x=-2, y=-1}}, - [1]={{x=0, y=1}, {x=0, y=-1}, {x=0, y=2}, {x=0, y=-2}}, - [2]={{x=-2, y=0}, {x=1, y=0}, {x=-2, y=1}, {x=1, y=-2}}, - }, -}; - -function SRS:check_new_low(piece) - for _, block in pairs(piece:getBlockOffsets()) do - local y = piece.position.y + block.y - if y > piece.lowest_y then - piece.manipulations = 0 - piece.lowest_y = y - end - end -end - --- Component functions. - -function SRS:attemptWallkicks(piece, new_piece, rot_dir, grid) - - local kicks - if piece.shape == "O" then - return - elseif piece.shape == "I" then - kicks = SRS.wallkicks_line[piece.rotation][new_piece.rotation] - else - kicks = SRS.wallkicks_3x3[piece.rotation][new_piece.rotation] - end - - assert(piece.rotation ~= new_piece.rotation) - - for idx, offset in pairs(kicks) do - kicked_piece = new_piece:withOffset(offset) - if grid:canPlacePiece(kicked_piece) then - piece:setRelativeRotation(rot_dir) - piece:setOffset(offset) - self:onPieceRotate(piece, grid) - return - end - end - -end - -function SRS:onPieceCreate(piece, grid) - piece.manipulations = 0 - piece.lowest_y = -math.huge -end - -function SRS:onPieceDrop(piece, grid) - self:check_new_low(piece) - if piece.manipulations >= 15 and piece:isDropBlocked(grid) then - piece.locked = true - else - piece.lock_delay = 0 -- step reset - end -end - -function SRS:onPieceMove(piece, grid) - piece.lock_delay = 0 -- move reset - if piece:isDropBlocked(grid) then - piece.manipulations = piece.manipulations + 1 - if piece.manipulations >= 15 then - piece.locked = true - end - end -end +SRS.MANIPULATIONS_MAX = 15 function SRS:onPieceRotate(piece, grid) piece.lock_delay = 0 -- rotate reset self:check_new_low(piece) piece.manipulations = piece.manipulations + 1 if piece:isDropBlocked(grid) then - if piece.manipulations >= 15 then + if piece.manipulations >= SRS.MANIPULATIONS_MAX then piece.locked = true end end diff --git a/tetris/rulesets/standard_exp.lua b/tetris/rulesets/standard_exp.lua index b73d56a..c8737a8 100755 --- a/tetris/rulesets/standard_exp.lua +++ b/tetris/rulesets/standard_exp.lua @@ -15,8 +15,8 @@ SRS.colourscheme = { O = "Y", T = "M", } -SRS.softdrop_lock = false -SRS.harddrop_lock = true +SRS.softdrop_lock = true +SRS.harddrop_lock = false SRS.enable_IRS_wallkicks = true @@ -103,7 +103,7 @@ function SRS:onPieceMove(piece, grid) piece.lock_delay = 0 -- move reset if piece:isDropBlocked(grid) then piece.manipulations = piece.manipulations + 1 - if piece.manipulations >= 24 then + if piece.manipulations >= SRS.MANIPULATIONS_MAX then piece.locked = true end end