Fixed RNG in replays being different each time
parent
9a47018a58
commit
52473c2787
|
@ -561,7 +561,7 @@ function LifeGrid:advanceLife()
|
|||
if (count == 3) and (newgrid[y][x] == empty) then
|
||||
newgrid[y][x] = {
|
||||
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
|
||||
|
|
|
@ -44,7 +44,7 @@ local maps = {
|
|||
function ComboChallenge:new()
|
||||
GameMode:new()
|
||||
self.grid = Grid(4, 24)
|
||||
self.grid:applyMap(maps[math.random(#maps)])
|
||||
self.grid:applyMap(maps[love.math.random(#maps)])
|
||||
self.randomizer = BagRandomizer()
|
||||
self.lock_drop = false
|
||||
self.lock_hard_drop = false
|
||||
|
|
|
@ -27,7 +27,7 @@ function DemonModeGame:new()
|
|||
self.lock_drop = true
|
||||
self.lock_hard_drop = true
|
||||
self.next_queue_length = 6
|
||||
if math.random() < 1/6.66 then
|
||||
if love.math.random() < 1/6.66 then
|
||||
self.rpc_details = "Suffering"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -135,25 +135,25 @@ function TheTrueHero:advanceOneFrame(inputs, ruleset)
|
|||
) and (attack_rolls < 2)) or attack_rolls == 0 do
|
||||
attack_rolls = attack_rolls + 1
|
||||
if self.attack_number > 20 then
|
||||
self.current_attack = math.random(#self.attacks)
|
||||
self.current_attack = love.math.random(#self.attacks)
|
||||
else
|
||||
self.current_attack = math.random(4)
|
||||
self.current_attack = love.math.random(4)
|
||||
end
|
||||
end
|
||||
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 / 3)
|
||||
) *
|
||||
self.section_times[Mod1(self.attack_number, #self.section_times)] / 342)
|
||||
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 / 4)
|
||||
) *
|
||||
self.section_times[Mod1(self.attack_number, #self.section_times)] / 342)
|
||||
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 / 4)
|
||||
), 3)
|
||||
|
@ -212,7 +212,7 @@ end
|
|||
function TheTrueHero:advanceBottomRow(dx)
|
||||
if self.var <= 0 and self.current_attack == 3 then
|
||||
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 / 4)
|
||||
), 3)
|
||||
|
|
|
@ -330,9 +330,9 @@ function MarathonC99Game:drawScoringInfo()
|
|||
{1, 1, 1, 1}
|
||||
)
|
||||
love.graphics.printf(
|
||||
(self.slots[1] and self.slots[1] or math.random(4)) .. " " ..
|
||||
(self.slots[2] and self.slots[2] or math.random(4)) .. " " ..
|
||||
math.random(4),
|
||||
(self.slots[1] and self.slots[1] or love.math.random(4)) .. " " ..
|
||||
(self.slots[2] and self.slots[2] or love.math.random(4)) .. " " ..
|
||||
love.math.random(4),
|
||||
240, 80, 100, "left")
|
||||
love.graphics.setColor(1,1,1,1)
|
||||
end
|
||||
|
|
|
@ -93,7 +93,7 @@ function MarathonWCBGame:shuffleColours()
|
|||
table.insert(temp_colours, colour)
|
||||
end
|
||||
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
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ end
|
|||
function Minesweeper:initializeGrid()
|
||||
self.grid = Grid(width, height + 4)
|
||||
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 x = 1, width do
|
||||
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
|
||||
local x, y
|
||||
repeat
|
||||
x = math.random(1, width)
|
||||
y = math.random(1, height)
|
||||
x = love.math.random(1, width)
|
||||
y = love.math.random(1, height)
|
||||
until not (self:isMine(x, y) or (sel_x == x and sel_y == y))
|
||||
table.insert(self.mines, {x=x, y=y})
|
||||
end
|
||||
|
|
|
@ -59,8 +59,8 @@ end
|
|||
|
||||
function Snake:generateGem()
|
||||
repeat
|
||||
self.gem.x = math.random(1, 25)
|
||||
self.gem.y = math.random(5, 24)
|
||||
self.gem.x = love.math.random(1, 25)
|
||||
self.gem.y = love.math.random(5, 24)
|
||||
until not self:isInSnake({x=self.gem.x, y=self.gem.y})
|
||||
end
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ function StackerGame:advanceOneFrame(inputs, ruleset)
|
|||
self.are = self.are - 1
|
||||
return false
|
||||
elseif self.are == 0 then
|
||||
self.position = math.random(1, 7 + self.block_width - 1)
|
||||
self.direction = ({-1, 1})[math.random(2)]
|
||||
self.position = love.math.random(1, 7 + self.block_width - 1)
|
||||
self.direction = ({-1, 1})[love.math.random(2)]
|
||||
self.are = -1
|
||||
end
|
||||
if not self.prev_inputs.up and inputs.up then
|
||||
|
|
|
@ -10,7 +10,7 @@ function Bag5Randomizer:generatePiece()
|
|||
if next(self.bag) == nil then
|
||||
self.bag = {"I", "J", "L", "O", "T"}
|
||||
end
|
||||
local x = math.random(table.getn(self.bag))
|
||||
local x = love.math.random(table.getn(self.bag))
|
||||
return table.remove(self.bag, x)
|
||||
end
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ function Bag5AltRandomizer:generatePiece()
|
|||
if next(self.bag) == nil then
|
||||
self.bag = {"I", "J", "L", "O", "T"}
|
||||
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)
|
||||
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)
|
||||
end
|
||||
self.prev = temp
|
||||
|
|
|
@ -18,7 +18,7 @@ function Bag63Randomiser:generatePiece()
|
|||
"O", "O", "O", "O", "O", "O", "O", "O", "O",
|
||||
}
|
||||
end
|
||||
return table.remove(self.bag, math.random(#self.bag))
|
||||
return table.remove(self.bag, love.math.random(#self.bag))
|
||||
end
|
||||
|
||||
return Bag63Randomiser
|
|
@ -5,7 +5,7 @@ local Bag7Randomizer = Randomizer:extend()
|
|||
function Bag7Randomizer:initialize()
|
||||
self.bag = {"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
|
||||
|
||||
function Bag7Randomizer:generatePiece()
|
||||
|
@ -14,9 +14,9 @@ function Bag7Randomizer:generatePiece()
|
|||
end
|
||||
if next(self.bag) == nil then
|
||||
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
|
||||
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, ", "))
|
||||
return table.remove(self.bag, x)
|
||||
end
|
||||
|
|
|
@ -14,10 +14,10 @@ function BagKonoha:generatePiece()
|
|||
if #self.bag == 0 then
|
||||
self.bag = {"I", "J", "L", "O", "T"}
|
||||
end
|
||||
local x = math.random(#self.bag)
|
||||
local x = love.math.random(#self.bag)
|
||||
local temp = table.remove(self.bag, x)
|
||||
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
|
||||
temp = table.remove(self.bag, y)
|
||||
end
|
||||
|
|
|
@ -58,7 +58,7 @@ function DTETRandomizer:generatePiece()
|
|||
end
|
||||
|
||||
-- pull piece from 21-bag and update drought counters
|
||||
local generated = bag[love.math.random(#bag)]
|
||||
local generated = bag[love.love.math.random(#bag)]
|
||||
self:updateDroughts(generated)
|
||||
return generated
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ end
|
|||
function EXRandomizer:generatePiece()
|
||||
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||
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
|
||||
return self:updateHistory(shapes[x])
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ end
|
|||
|
||||
function HistoryRandomizer:generatePiece()
|
||||
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
|
||||
return self:updateHistory(self.allowed_pieces[x])
|
||||
end
|
||||
|
|
|
@ -12,19 +12,19 @@ function MasterOfBags:initialize()
|
|||
end
|
||||
|
||||
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
|
||||
self.bag={}
|
||||
for x=1,28 do
|
||||
self.bag[x]=({"I", "J", "L", "O", "S", "T", "Z"})[(x-1)%7+1]
|
||||
end
|
||||
piece=math.random(#self.bag)
|
||||
piece=love.math.random(#self.bag)
|
||||
end
|
||||
for i = 1, 6 do
|
||||
if not inHistory(self.bag[piece], self.history) then
|
||||
break
|
||||
end
|
||||
piece=math.random(#self.bag)
|
||||
piece=love.math.random(#self.bag)
|
||||
end
|
||||
self:updateHistory(self.bag[piece])
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ function MirrorRandomizer:generatePiece()
|
|||
generated = table.remove(self.piece_stack)
|
||||
else
|
||||
repeat
|
||||
generated = self.shapes[math.random(7)]
|
||||
generated = self.shapes[love.math.random(7)]
|
||||
until not inHistory(generated, self.history)
|
||||
table.remove(self.history, 1)
|
||||
table.insert(self.history, generated)
|
||||
|
|
|
@ -8,9 +8,9 @@ function NES:initialize()
|
|||
end
|
||||
|
||||
function NES:generatePiece()
|
||||
local x = math.random(8)
|
||||
local x = love.math.random(8)
|
||||
if x == 8 or x == self.history then
|
||||
x = math.random(7)
|
||||
x = love.math.random(7)
|
||||
end
|
||||
self.history = x
|
||||
return self.shapes[x]
|
||||
|
|
|
@ -10,7 +10,7 @@ function RecursiveRandomizer:generatePiece()
|
|||
--if next(self.bag) == nil then
|
||||
-- self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||
--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
|
||||
--print("Refill piece pulled")
|
||||
table.insert(self.bag, "I")
|
||||
|
@ -20,7 +20,7 @@ function RecursiveRandomizer:generatePiece()
|
|||
table.insert(self.bag, "S")
|
||||
table.insert(self.bag, "T")
|
||||
table.insert(self.bag, "Z")
|
||||
x = math.random(table.getn(self.bag) + 1)
|
||||
x = love.math.random(table.getn(self.bag) + 1)
|
||||
end
|
||||
--print("Number of pieces in bag: "..table.getn(self.bag))
|
||||
--print("Bag: "..table.concat(self.bag, ", "))
|
||||
|
|
|
@ -6,7 +6,7 @@ function SegaRandomizer:initialize()
|
|||
self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||
self.sequence = {}
|
||||
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
|
||||
self.counter = 0
|
||||
end
|
||||
|
|
|
@ -10,11 +10,11 @@ end
|
|||
function SplitHistoryRandomizer:generatePiece()
|
||||
if self.piece_count < 2 then
|
||||
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
|
||||
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||
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
|
||||
return self:updateHistory(shapes[x])
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ end
|
|||
function TetraXRandomizer:generatePiece()
|
||||
local generated = nil
|
||||
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
|
||||
break
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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}}
|
||||
|
|
Loading…
Reference in New Issue