Merge pull request #15 from Tetro48/main

Replay compatibility and adherence to new ruleset names
pull/6/merge
Ishaan Bhardwaj 2023-06-23 18:03:15 -04:00 committed by GitHub
commit 152c37eac5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 68 additions and 68 deletions

View File

@ -561,7 +561,7 @@ function LifeGrid:advanceLife()
if (count == 3) and (newgrid[y][x] == empty) then if (count == 3) and (newgrid[y][x] == empty) then
newgrid[y][x] = { newgrid[y][x] = {
skin = "2tie", skin = "2tie",
colour = ({"R", "O", "Y", "G", "B", "C", "M"})[math.random(7)] colour = ({"R", "O", "Y", "G", "B", "C", "M"})[love.math.random(7)]
} }
end end
end end

View File

@ -44,7 +44,7 @@ local maps = {
function ComboChallenge:new() function ComboChallenge:new()
GameMode:new() GameMode:new()
self.grid = Grid(4, 24) self.grid = Grid(4, 24)
self.grid:applyMap(maps[math.random(#maps)]) self.grid:applyMap(maps[love.math.random(#maps)])
self.randomizer = BagRandomizer() self.randomizer = BagRandomizer()
self.lock_drop = false self.lock_drop = false
self.lock_hard_drop = false self.lock_hard_drop = false

View File

@ -27,7 +27,7 @@ function DemonModeGame:new()
self.lock_drop = true self.lock_drop = true
self.lock_hard_drop = true self.lock_hard_drop = true
self.next_queue_length = 6 self.next_queue_length = 6
if math.random() < 1/6.66 then if love.math.random() < 1/6.66 then
self.rpc_details = "Suffering" self.rpc_details = "Suffering"
end end
end end

View File

@ -135,25 +135,25 @@ function TheTrueHero:advanceOneFrame(inputs, ruleset)
) and (attack_rolls < 2)) or attack_rolls == 0 do ) and (attack_rolls < 2)) or attack_rolls == 0 do
attack_rolls = attack_rolls + 1 attack_rolls = attack_rolls + 1
if self.attack_number > 20 then if self.attack_number > 20 then
self.current_attack = math.random(#self.attacks) self.current_attack = love.math.random(#self.attacks)
else else
self.current_attack = math.random(4) self.current_attack = love.math.random(4)
end end
end end
if self.current_attack == 1 then if self.current_attack == 1 then
self.var = math.floor(3 + math.random( self.var = math.floor(3 + love.math.random(
math.floor(self.attack_number / 4), math.floor(self.attack_number / 4),
math.floor(self.attack_number / 3) math.floor(self.attack_number / 3)
) * ) *
self.section_times[Mod1(self.attack_number, #self.section_times)] / 342) self.section_times[Mod1(self.attack_number, #self.section_times)] / 342)
elseif self.current_attack == 2 then elseif self.current_attack == 2 then
self.var = math.floor(1 + math.random( self.var = math.floor(1 + love.math.random(
math.floor(self.attack_number / 6), math.floor(self.attack_number / 6),
math.floor(self.attack_number / 4) math.floor(self.attack_number / 4)
) * ) *
self.section_times[Mod1(self.attack_number, #self.section_times)] / 342) self.section_times[Mod1(self.attack_number, #self.section_times)] / 342)
elseif self.current_attack == 3 then elseif self.current_attack == 3 then
self.var = math.max(10 - math.random( self.var = math.max(10 - love.math.random(
math.floor(self.attack_number / 8), math.floor(self.attack_number / 8),
math.floor(self.attack_number / 4) math.floor(self.attack_number / 4)
), 3) ), 3)
@ -212,7 +212,7 @@ end
function TheTrueHero:advanceBottomRow(dx) function TheTrueHero:advanceBottomRow(dx)
if self.var <= 0 and self.current_attack == 3 then if self.var <= 0 and self.current_attack == 3 then
self.grid:copyBottomRow() self.grid:copyBottomRow()
self.var = math.max(10 - math.random( self.var = math.max(10 - love.math.random(
math.floor(self.attack_number / 8), math.floor(self.attack_number / 8),
math.floor(self.attack_number / 4) math.floor(self.attack_number / 4)
), 3) ), 3)

View File

@ -93,7 +93,7 @@ function MarathonWCBGame:shuffleColours()
table.insert(temp_colours, colour) table.insert(temp_colours, colour)
end end
for piece in pairs(self.ruleset.colourscheme) do for piece in pairs(self.ruleset.colourscheme) do
self.ruleset.colourscheme[piece] = table.remove(temp_colours, math.random(#temp_colours)) self.ruleset.colourscheme[piece] = table.remove(temp_colours, love.math.random(#temp_colours))
end end
end end

View File

@ -33,7 +33,7 @@ end
function Minesweeper:initializeGrid() function Minesweeper:initializeGrid()
self.grid = Grid(width, height + 4) self.grid = Grid(width, height + 4)
self.flags = math.floor(0.15 * width * height) self.flags = math.floor(0.15 * width * height)
self.chosen_colour = ({ "R", "O", "Y", "G", "C", "B", "M" })[math.random(7)] self.chosen_colour = ({ "R", "O", "Y", "G", "C", "B", "M" })[love.math.random(7)]
for y = 1, height do for y = 1, height do
for x = 1, width do for x = 1, width do
self.grid.grid[y+4][x] = { skin = "2tie", colour = self.chosen_colour } self.grid.grid[y+4][x] = { skin = "2tie", colour = self.chosen_colour }
@ -45,8 +45,8 @@ function Minesweeper:initializeMines(sel_x, sel_y)
for i = 1, self.flags do for i = 1, self.flags do
local x, y local x, y
repeat repeat
x = math.random(1, width) x = love.math.random(1, width)
y = math.random(1, height) y = love.math.random(1, height)
until not (self:isMine(x, y) or (sel_x == x and sel_y == y)) until not (self:isMine(x, y) or (sel_x == x and sel_y == y))
table.insert(self.mines, {x=x, y=y}) table.insert(self.mines, {x=x, y=y})
end end

View File

@ -59,8 +59,8 @@ end
function Snake:generateGem() function Snake:generateGem()
repeat repeat
self.gem.x = math.random(1, 25) self.gem.x = love.math.random(1, 25)
self.gem.y = math.random(5, 24) self.gem.y = love.math.random(5, 24)
until not self:isInSnake({x=self.gem.x, y=self.gem.y}) until not self:isInSnake({x=self.gem.x, y=self.gem.y})
end end

View File

@ -55,8 +55,8 @@ function StackerGame:advanceOneFrame(inputs, ruleset)
self.are = self.are - 1 self.are = self.are - 1
return false return false
elseif self.are == 0 then elseif self.are == 0 then
self.position = math.random(1, 7 + self.block_width - 1) self.position = love.math.random(1, 7 + self.block_width - 1)
self.direction = ({-1, 1})[math.random(2)] self.direction = ({-1, 1})[love.math.random(2)]
self.are = -1 self.are = -1
end end
if not self.prev_inputs.up and inputs.up then if not self.prev_inputs.up and inputs.up then

View File

@ -10,7 +10,7 @@ function Bag5Randomizer:generatePiece()
if next(self.bag) == nil then if next(self.bag) == nil then
self.bag = {"I", "J", "L", "O", "T"} self.bag = {"I", "J", "L", "O", "T"}
end end
local x = math.random(table.getn(self.bag)) local x = love.math.random(table.getn(self.bag))
return table.remove(self.bag, x) return table.remove(self.bag, x)
end end

View File

@ -11,10 +11,10 @@ function Bag5AltRandomizer:generatePiece()
if next(self.bag) == nil then if next(self.bag) == nil then
self.bag = {"I", "J", "L", "O", "T"} self.bag = {"I", "J", "L", "O", "T"}
end end
local x = math.random(table.getn(self.bag)) local x = love.math.random(table.getn(self.bag))
local temp = table.remove(self.bag, x) local temp = table.remove(self.bag, x)
if temp == self.prev then if temp == self.prev then
local y = math.random(table.getn(self.bag)) local y = love.math.random(table.getn(self.bag))
temp = table.remove(self.bag, y) temp = table.remove(self.bag, y)
end end
self.prev = temp self.prev = temp

View File

@ -18,7 +18,7 @@ function Bag63Randomiser:generatePiece()
"O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O",
} }
end end
return table.remove(self.bag, math.random(#self.bag)) return table.remove(self.bag, love.math.random(#self.bag))
end end
return Bag63Randomiser return Bag63Randomiser

View File

@ -5,7 +5,7 @@ local Bag7Randomizer = Randomizer:extend()
function Bag7Randomizer:initialize() function Bag7Randomizer:initialize()
self.bag = {"I", "J", "L", "O", "S", "T", "Z"} self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
self.extra = {"I", "J", "L", "O", "S", "T", "Z"} self.extra = {"I", "J", "L", "O", "S", "T", "Z"}
table.insert(self.bag, table.remove(self.extra, math.random(table.getn(self.extra)))) table.insert(self.bag, table.remove(self.extra, love.math.random(table.getn(self.extra))))
end end
function Bag7Randomizer:generatePiece() function Bag7Randomizer:generatePiece()
@ -14,9 +14,9 @@ function Bag7Randomizer:generatePiece()
end end
if next(self.bag) == nil then if next(self.bag) == nil then
self.bag = {"I", "J", "L", "O", "S", "T", "Z"} self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
table.insert(self.bag, table.remove(self.extra, math.random(table.getn(self.extra)))) table.insert(self.bag, table.remove(self.extra, love.math.random(table.getn(self.extra))))
end end
local x = math.random(table.getn(self.bag)) local x = love.math.random(table.getn(self.bag))
--print("Bag: "..table.concat(self.bag, ", ").." | Extra: "..table.concat(self.extra, ", ")) --print("Bag: "..table.concat(self.bag, ", ").." | Extra: "..table.concat(self.extra, ", "))
return table.remove(self.bag, x) return table.remove(self.bag, x)
end end

View File

@ -14,10 +14,10 @@ function BagKonoha:generatePiece()
if #self.bag == 0 then if #self.bag == 0 then
self.bag = {"I", "J", "L", "O", "T"} self.bag = {"I", "J", "L", "O", "T"}
end end
local x = math.random(#self.bag) local x = love.math.random(#self.bag)
local temp = table.remove(self.bag, x) local temp = table.remove(self.bag, x)
if temp == self.prev and not self.allowrepeat then if temp == self.prev and not self.allowrepeat then
local y = math.random(#self.bag) local y = love.math.random(#self.bag)
table.insert(self.bag, temp) -- should insert at the end of the bag, bag[y] doesnt change table.insert(self.bag, temp) -- should insert at the end of the bag, bag[y] doesnt change
temp = table.remove(self.bag, y) temp = table.remove(self.bag, y)
end end

View File

@ -58,7 +58,7 @@ function DTETRandomizer:generatePiece()
end end
-- pull piece from 21-bag and update drought counters -- pull piece from 21-bag and update drought counters
local generated = bag[math.random(#bag)] local generated = bag[love.love.math.random(#bag)]
self:updateDroughts(generated) self:updateDroughts(generated)
return generated return generated
end end

View File

@ -9,7 +9,7 @@ end
function EXRandomizer:generatePiece() function EXRandomizer:generatePiece()
local shapes = {"I", "J", "L", "O", "S", "T", "Z"} local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
for i = 1, 6 do for i = 1, 6 do
local x = math.random(7) local x = love.math.random(7)
if not inHistory(shapes[x], self.history) or i == 6 then if not inHistory(shapes[x], self.history) or i == 6 then
return self:updateHistory(shapes[x]) return self:updateHistory(shapes[x])
end end

View File

@ -14,7 +14,7 @@ end
function HistoryRandomizer:generatePiece() function HistoryRandomizer:generatePiece()
for i = 1, self.rolls do for i = 1, self.rolls do
local x = math.random(table.getn(self.allowed_pieces)) local x = love.math.random(table.getn(self.allowed_pieces))
if not inHistory(self.allowed_pieces[x], self.history) or i == self.rolls then if not inHistory(self.allowed_pieces[x], self.history) or i == self.rolls then
return self:updateHistory(self.allowed_pieces[x]) return self:updateHistory(self.allowed_pieces[x])
end end

View File

@ -12,19 +12,19 @@ function MasterOfBags:initialize()
end end
function MasterOfBags:generatePiece() function MasterOfBags:generatePiece()
local piece=math.random(({[true]=#self.bag,[false]=#self.bag+1})[#self.bag>14]) local piece=love.math.random(({[true]=#self.bag,[false]=#self.bag+1})[#self.bag>14])
if piece>#self.bag then if piece>#self.bag then
self.bag={} self.bag={}
for x=1,28 do for x=1,28 do
self.bag[x]=({"I", "J", "L", "O", "S", "T", "Z"})[(x-1)%7+1] self.bag[x]=({"I", "J", "L", "O", "S", "T", "Z"})[(x-1)%7+1]
end end
piece=math.random(#self.bag) piece=love.math.random(#self.bag)
end end
for i = 1, 6 do for i = 1, 6 do
if not inHistory(self.bag[piece], self.history) then if not inHistory(self.bag[piece], self.history) then
break break
end end
piece=math.random(#self.bag) piece=love.math.random(#self.bag)
end end
self:updateHistory(self.bag[piece]) self:updateHistory(self.bag[piece])

View File

@ -35,7 +35,7 @@ function MirrorRandomizer:generatePiece()
generated = table.remove(self.piece_stack) generated = table.remove(self.piece_stack)
else else
repeat repeat
generated = self.shapes[math.random(7)] generated = self.shapes[love.math.random(7)]
until not inHistory(generated, self.history) until not inHistory(generated, self.history)
table.remove(self.history, 1) table.remove(self.history, 1)
table.insert(self.history, generated) table.insert(self.history, generated)

View File

@ -8,9 +8,9 @@ function NES:initialize()
end end
function NES:generatePiece() function NES:generatePiece()
local x = math.random(8) local x = love.math.random(8)
if x == 8 or x == self.history then if x == 8 or x == self.history then
x = math.random(7) x = love.math.random(7)
end end
self.history = x self.history = x
return self.shapes[x] return self.shapes[x]

View File

@ -10,7 +10,7 @@ function RecursiveRandomizer:generatePiece()
--if next(self.bag) == nil then --if next(self.bag) == nil then
-- self.bag = {"I", "J", "L", "O", "S", "T", "Z"} -- self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
--end --end
local x = math.random(table.getn(self.bag) + 1) local x = love.math.random(table.getn(self.bag) + 1)
while x == table.getn(self.bag) + 1 do while x == table.getn(self.bag) + 1 do
--print("Refill piece pulled") --print("Refill piece pulled")
table.insert(self.bag, "I") table.insert(self.bag, "I")
@ -20,7 +20,7 @@ function RecursiveRandomizer:generatePiece()
table.insert(self.bag, "S") table.insert(self.bag, "S")
table.insert(self.bag, "T") table.insert(self.bag, "T")
table.insert(self.bag, "Z") table.insert(self.bag, "Z")
x = math.random(table.getn(self.bag) + 1) x = love.math.random(table.getn(self.bag) + 1)
end end
--print("Number of pieces in bag: "..table.getn(self.bag)) --print("Number of pieces in bag: "..table.getn(self.bag))
--print("Bag: "..table.concat(self.bag, ", ")) --print("Bag: "..table.concat(self.bag, ", "))

View File

@ -6,7 +6,7 @@ function SegaRandomizer:initialize()
self.bag = {"I", "J", "L", "O", "S", "T", "Z"} self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
self.sequence = {} self.sequence = {}
for i = 1, 1000 do for i = 1, 1000 do
self.sequence[i] = self.bag[math.random(table.getn(self.bag))] self.sequence[i] = self.bag[love.math.random(table.getn(self.bag))]
end end
self.counter = 0 self.counter = 0
end end

View File

@ -10,11 +10,11 @@ end
function SplitHistoryRandomizer:generatePiece() function SplitHistoryRandomizer:generatePiece()
if self.piece_count < 2 then if self.piece_count < 2 then
self.piece_count = self.piece_count + 1 self.piece_count = self.piece_count + 1
return self:updateHistory(({"L", "J", "I", "T"})[math.random(4)]) return self:updateHistory(({"L", "J", "I", "T"})[love.math.random(4)])
else else
local shapes = {"I", "J", "L", "O", "S", "T", "Z"} local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
for i = 1, 4 do for i = 1, 4 do
local x = math.random(7) local x = love.math.random(7)
if not inHistory(shapes[x], self.history) or i == 4 then if not inHistory(shapes[x], self.history) or i == 4 then
return self:updateHistory(shapes[x]) return self:updateHistory(shapes[x])
end end

View File

@ -28,7 +28,7 @@ end
function TetraXRandomizer:generatePiece() function TetraXRandomizer:generatePiece()
local generated = nil local generated = nil
while true do while true do
generated = self.pieceselection[math.random(#self.pieceselection)] generated = self.pieceselection[love.math.random(#self.pieceselection)]
if not (self.lastseen[generated] == 0 or self.lastseen[generated] == 1) then if not (self.lastseen[generated] == 0 or self.lastseen[generated] == 1) then
break break
end end

View File

@ -8,13 +8,13 @@ CRAP.hash = "Completely Random Auto-Positioner"
CRAP.world = true CRAP.world = true
CRAP.colors={"C","O","M","R","G","Y","B"} CRAP.colors={"C","O","M","R","G","Y","B"}
CRAP.colourscheme = { CRAP.colourscheme = {
I = CRAP.colors[math.ceil(math.random(7))], I = CRAP.colors[math.ceil(love.math.random(7))],
L = CRAP.colors[math.ceil(math.random(7))], L = CRAP.colors[math.ceil(love.math.random(7))],
J = CRAP.colors[math.ceil(math.random(7))], J = CRAP.colors[math.ceil(love.math.random(7))],
S = CRAP.colors[math.ceil(math.random(7))], S = CRAP.colors[math.ceil(love.math.random(7))],
Z = CRAP.colors[math.ceil(math.random(7))], Z = CRAP.colors[math.ceil(love.math.random(7))],
O = CRAP.colors[math.ceil(math.random(7))], O = CRAP.colors[math.ceil(love.math.random(7))],
T = CRAP.colors[math.ceil(math.random(7))], T = CRAP.colors[math.ceil(love.math.random(7))],
} }
CRAP.softdrop_lock = true CRAP.softdrop_lock = true
CRAP.harddrop_lock = false CRAP.harddrop_lock = false
@ -111,8 +111,8 @@ end
function CRAP:attemptWallkicks(piece, new_piece, rot_dir, grid) function CRAP:attemptWallkicks(piece, new_piece, rot_dir, grid)
for i=1,20 do for i=1,20 do
dx=math.floor(math.random(11))-5 dx=math.floor(love.math.random(11))-5
dy=math.floor(math.random(11))-5 dy=math.floor(love.math.random(11))-5
if grid:canPlacePiece(new_piece:withOffset({x=dx, y=dy})) then if grid:canPlacePiece(new_piece:withOffset({x=dx, y=dy})) then
self:onPieceRotate(piece, grid) self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir):setOffset({x=dx, y=dy}) piece:setRelativeRotation(rot_dir):setOffset({x=dx, y=dy})
@ -147,13 +147,13 @@ function CRAP:get180RotationValue() return 2 end
function CRAP:randomizeColours() function CRAP:randomizeColours()
CRAP.colourscheme = { CRAP.colourscheme = {
I = CRAP.colors[math.ceil(math.random(7))], I = CRAP.colors[math.ceil(love.math.random(7))],
L = CRAP.colors[math.ceil(math.random(7))], L = CRAP.colors[math.ceil(love.math.random(7))],
J = CRAP.colors[math.ceil(math.random(7))], J = CRAP.colors[math.ceil(love.math.random(7))],
S = CRAP.colors[math.ceil(math.random(7))], S = CRAP.colors[math.ceil(love.math.random(7))],
Z = CRAP.colors[math.ceil(math.random(7))], Z = CRAP.colors[math.ceil(love.math.random(7))],
O = CRAP.colors[math.ceil(math.random(7))], O = CRAP.colors[math.ceil(love.math.random(7))],
T = CRAP.colors[math.ceil(math.random(7))], T = CRAP.colors[math.ceil(love.math.random(7))],
} }
end end

View File

@ -1,4 +1,4 @@
local SRS = require 'tetris.rulesets.arika_srs' local SRS = require 'tetris.rulesets.standard_ace'
local Cultris = SRS:extend() local Cultris = SRS:extend()

View File

@ -1,4 +1,4 @@
local SRS = require 'tetris.rulesets.arika_srs' local SRS = require 'tetris.rulesets.standard_ace'
local EARS = SRS:extend() local EARS = SRS:extend()

View File

@ -31,7 +31,7 @@ function H:attemptRotate(new_inputs, piece, grid, initial)
end end
function H:getDefaultOrientation() function H:getDefaultOrientation()
return math.random(4) return love.math.random(4)
end end
return H return H

View File

@ -1,4 +1,4 @@
local SRS = require 'tetris.rulesets.ti_srs' local SRS = require 'tetris.rulesets.standard_ti'
local KRS = SRS:extend() local KRS = SRS:extend()

View File

@ -23,8 +23,8 @@ function RandomPieces:generateBlockOffsets()
local generated_offset = {} local generated_offset = {}
repeat repeat
generated_offset = { generated_offset = {
x = math.random(-1, 1), x = love.math.random(-1, 1),
y = math.random(-2, 0) y = love.math.random(-2, 0)
} }
until not containsPoint(offsets, generated_offset) until not containsPoint(offsets, generated_offset)
offsets[i] = generated_offset offsets[i] = generated_offset

View File

@ -89,7 +89,7 @@ function Shirase:onPieceMove(piece) piece.lock_delay = 0 end
function Shirase:onPieceRotate(piece) piece.lock_delay = 0 end function Shirase:onPieceRotate(piece) piece.lock_delay = 0 end
function Shirase:getDefaultOrientation() function Shirase:getDefaultOrientation()
return math.random(4) return love.math.random(4)
end end
return Shirase return Shirase

View File

@ -1,4 +1,4 @@
local SRS = require 'tetris.rulesets.arika_srs' local SRS = require 'tetris.rulesets.standard_ace'
local Tetra = SRS:extend() local Tetra = SRS:extend()

View File

@ -1,4 +1,4 @@
local SRS = require 'tetris.rulesets.ti_srs' local SRS = require 'tetris.rulesets.standard_ti'
local TexyWorld = SRS:extend() local TexyWorld = SRS:extend()

View File

@ -1,4 +1,4 @@
local SRS = require 'tetris.rulesets.arika_srs' local SRS = require 'tetris.rulesets.standard_ace'
local TOD = SRS:extend() local TOD = SRS:extend()

View File

@ -35,7 +35,7 @@ end
function Trans:attemptWallkicks(piece, new_piece, rot_dir, grid) function Trans:attemptWallkicks(piece, new_piece, rot_dir, grid)
local pieces = {"I", "J", "L", "O", "S", "T", "Z"} local pieces = {"I", "J", "L", "O", "S", "T", "Z"}
repeat repeat
new_piece.shape = pieces[math.random(7)] new_piece.shape = pieces[love.math.random(7)]
until piece.shape ~= new_piece.shape until piece.shape ~= new_piece.shape
local offsets = {{x=0, y=0}, {x=1, y=0}, {x=-1, y=0}} local offsets = {{x=0, y=0}, {x=1, y=0}, {x=-1, y=0}}