Compare commits

...

3 Commits

Author SHA1 Message Date
Ishaan Bhardwaj
c7926b2843 New Ludicrous Speed PPS algorithm 2022-01-30 17:05:59 -05:00
Ishaan Bhardwaj
bc50d75b9a Fixed GTE spawn logic 2021-11-27 16:09:41 -05:00
Ishaan Bhardwaj
d837b14c53 Fixed IRS triggering transform in TransRS 2021-11-27 16:08:54 -05:00
3 changed files with 68 additions and 43 deletions

View File

@ -14,9 +14,9 @@ function LudicrousSpeed:new()
self.super:new()
self.time_limit = 300
self.pps = {}
self.delays = {}
self.last_piece = 0
self.pps_limit = 1
self.pieces = 0
self.randomizer = Bag7Randomizer()
@ -28,6 +28,16 @@ function LudicrousSpeed:new()
self.next_queue_length = 6
end
local function mean(t)
local sum = 0
for _, v in ipairs(t) do
sum = sum + v
end
return sum / #t
end
function LudicrousSpeed:getGravity()
if self.lines < 180 then
return (0.8 - (math.floor(self.lines / 10) * 0.007)) ^ -math.floor(self.lines / 10) / 60
@ -42,41 +52,31 @@ function LudicrousSpeed:getARR() return config.arr end
function LudicrousSpeed:getDasCutDelay() return config.dcd end
function LudicrousSpeed:getDropSpeed() return 20 end
local function mean(t)
local sum = 0
local count = 0
for k, v in pairs(t) do
if type(v) == 'number' then
sum = sum + v
count = count + 1
end
end
return (sum / count)
function LudicrousSpeed:getPPS()
if #self.delays == 0 then return 0 end
local delays = copy(self.delays)
delays[#delays + 1] = self.frames - self.last_piece
return (mean(delays) / 60) ^ -1
end
function LudicrousSpeed:advanceOneFrame()
if self.ready_frames == 0 then
self.frames = self.frames + 1
if mean(self.pps) * 60 < self.pps_limit then
if self:getPPS() < self.pps_limit then
self.time_limit = self.time_limit - 1
self.game_over = self.time_limit <= 0
else self.time_limit = 300 end
if self.frames ~= 0 then
if table.getn(self.pps) == 750 then
table.remove(self.pps, 1)
table.insert(self.pps, self.pieces)
else table.insert(self.pps, self.pieces) end
self.pieces = 0
end
end
return true
end
function LudicrousSpeed:onPieceLock()
self.super:onPieceLock()
self.pieces = self.pieces + 1
function LudicrousSpeed:onPieceLock(...)
self.super:onPieceLock(...)
self.delays[#self.delays + 1] = self.frames - self.last_piece
if #self.delays >= 25 then
table.remove(self.delays, 1)
end
self.last_piece = self.frames
end
function LudicrousSpeed:onLineClear(cleared_row_count)
@ -114,7 +114,7 @@ function LudicrousSpeed:drawScoringInfo()
love.graphics.setFont(font_3x5_3)
love.graphics.printf(self.lines, text_x, 140, 80, "left")
love.graphics.printf(string.format("%.02f", self.frames > 0 and mean(self.pps) * 60 or 0), text_x, 200, 80, "left")
love.graphics.printf(string.format("%.02f", self:getPPS()), text_x, 200, 80, "left")
love.graphics.printf(string.format("%.02f", self.pps_limit), text_x, 260, 80, "left")
love.graphics.setFont(font_8x11)

View File

@ -56,6 +56,25 @@ function SurvivalGTEGame:onLineClear(cleared_row_count)
self.completed = self.lines >= 300
end
local function getLowestBlockY(offsets)
local res = -math.huge
for _, o in pairs(offsets) do
if o.y > res then
res = o.y
end
end
return res
end
function SurvivalGTEGame:onEnterOrHold(...)
while (
getLowestBlockY(self.piece:getBlockOffsets()) + self.piece.position.y
) < 4 do
self.piece.position.y = self.piece.position.y + 1
end
self.super.onEnterOrHold(self, ...)
end
function SurvivalGTEGame:advanceOneFrame()
if self.ready_frames == 0 then
self.frames = self.frames + 1

View File

@ -21,28 +21,34 @@ function Trans:attemptRotate(new_inputs, piece, grid, initial)
end
local new_piece = piece:withRelativeRotation(rot_dir)
if initial then
if (grid:canPlacePiece(new_piece)) then
self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir)
end
else
self:attemptWallkicks(piece, new_piece, rot_dir, grid)
end
end
function Trans:attemptWallkicks(piece, new_piece, rot_dir, grid)
local pieces = {"I", "J", "L", "O", "S", "T", "Z"}
repeat
new_piece.shape = pieces[math.random(7)]
until piece.shape ~= new_piece.shape
if (grid:canPlacePiece(new_piece)) then
self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir)
piece.shape = new_piece.shape
else
if not(initial and self.enable_IRS_wallkicks == false) then
if (grid:canPlacePiece(new_piece:withOffset({x=1, y=0}))) then
self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0})
piece.shape = new_piece.shape
elseif (grid:canPlacePiece(new_piece:withOffset({x=-1, y=0}))) then
self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0})
piece.shape = new_piece.shape
end
end
end
local offsets = {{x=0, y=0}, {x=1, y=0}, {x=-1, y=0}}
for _, o in pairs(offsets) do
local kicked_piece = new_piece:withOffset(o)
if (grid:canPlacePiece(kicked_piece)) then
self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir)
piece:setOffset(o)
piece.shape = new_piece.shape
return
end
end
end
return Trans