Fixed RNG in replays being different each time

This commit is contained in:
Tetro48
2023-06-14 12:06:16 +07:00
parent 9a47018a58
commit 52473c2787
29 changed files with 65 additions and 65 deletions

View File

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

View File

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

View File

@@ -23,8 +23,8 @@ function RandomPieces:generateBlockOffsets()
local generated_offset = {}
repeat
generated_offset = {
x = math.random(-1, 1),
y = math.random(-2, 0)
x = love.math.random(-1, 1),
y = love.math.random(-2, 0)
}
until not containsPoint(offsets, 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:getDefaultOrientation()
return math.random(4)
return love.math.random(4)
end
return Shirase

View File

@@ -35,7 +35,7 @@ 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)]
new_piece.shape = pieces[love.math.random(7)]
until piece.shape ~= new_piece.shape
local offsets = {{x=0, y=0}, {x=1, y=0}, {x=-1, y=0}}