Created
April 25, 2025 18:58
-
-
Save httpsterio/cb3f503e29c828913aa470970b85b63c to your computer and use it in GitHub Desktop.
balatro random seed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pseudoseed(key, predict_seed) | |
if key == 'seed' then return math.random() end | |
if predict_seed then | |
local _pseed = pseudohash(key..(predict_seed or '')) | |
_pseed = math.abs(tonumber(string.format("%.13f", (2.134453429141+_pseed*1.72431234)%1))) | |
return (_pseed + (pseudohash(predict_seed) or 0))/2 | |
end | |
if not G.GAME.pseudorandom[key] then | |
G.GAME.pseudorandom[key] = pseudohash(key..(G.GAME.pseudorandom.seed or '')) | |
end | |
G.GAME.pseudorandom[key] = math.abs(tonumber(string.format("%.13f", (2.134453429141+G.GAME.pseudorandom[key]*1.72431234)%1))) | |
return (G.GAME.pseudorandom[key] + (G.GAME.pseudorandom.hashed_seed or 0))/2 | |
end | |
/////////////////////////////////////// | |
if not card_protos then | |
card_protos = {} | |
for k, v in pairs(self.P_CARDS) do | |
local _ = nil | |
if self.GAME.starting_params.erratic_suits_and_ranks then _, k = pseudorandom_element(G.P_CARDS, pseudoseed('erratic')) end | |
local _r, _s = string.sub(k, 3, 3), string.sub(k, 1, 1) | |
local keep, _e, _d, _g = true, nil, nil, nil | |
if _de then | |
if _de.yes_ranks and not _de.yes_ranks[_r] then keep = false end | |
if _de.no_ranks and _de.no_ranks[_r] then keep = false end | |
if _de.yes_suits and not _de.yes_suits[_s] then keep = false end | |
if _de.no_suits and _de.no_suits[_s] then keep = false end | |
if _de.enhancement then _e = _de.enhancement end | |
if _de.edition then _d = _de.edition end | |
if _de.gold_seal then _g = _de.gold_seal end | |
end | |
if self.GAME.starting_params.no_faces and (_r == 'K' or _r == 'Q' or _r == 'J') then keep = false end | |
if keep then card_protos[#card_protos+1] = {s=_s,r=_r,e=_e,d=_d,g=_g} end | |
end | |
end | |
////////////////////////////// | |
function pseudorandom_element(_t, seed) | |
if seed then math.randomseed(seed) end | |
local keys = {} | |
for k, v in pairs(_t) do | |
keys[#keys+1] = {k = k,v = v} | |
end | |
if keys[1] and keys[1].v and type(keys[1].v) == 'table' and keys[1].v.sort_id then | |
table.sort(keys, function (a, b) return a.v.sort_id < b.v.sort_id end) | |
else | |
table.sort(keys, function (a, b) return a.k < b.k end) | |
end | |
local key = keys[math.random(#keys)].k | |
return _t[key], key | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment