1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00

Order of operations on Misc vs ores in map layout to allow glitter to take effect. Also implemented the poisson RNG

This commit is contained in:
TWLTriston 2017-11-15 05:53:49 -05:00
parent a4889d9f3b
commit edf992da12
3 changed files with 30 additions and 3 deletions

View File

@ -216,7 +216,7 @@ function check_decorative(tile, x, y)
for _,e in ipairs(options) do
name = e[1]
high_roll = e[2]
if math.random(1, high_roll) == 1 then
if poison_rng_next(high_roll / 2 ) == 1 then
table.insert(tile_decoratives, {name=name, amount=1, position={x,y}})
end
end
@ -323,7 +323,7 @@ function check_entities(tile, x, y)
for _,e in ipairs(options) do
name = e[1]
high_roll = e[2]
if math.random(1, high_roll) == 1 then
if poison_rng_next( high_roll / 2 ) == 1 then
table.insert(tile_entity_list, {name=name, position={x,y}})
end
end

View File

@ -0,0 +1,27 @@
local function generate_pmf_chart(l)
chart = {[0] = math.exp(-l)}
for k=1,(l*2 + 1) do
chart[k] = (chart[k - 1] * l / k)
end
return chart
end
local function generate_poisson_set(l, n) --n defines the resolution
local chart = generate_pmf_chart(l)
local set = {}
for x,y in pairs(chart) do
local m = math.floor(y * n + 0.5)
for i=0,m do
table.insert(set,x)
end
end
return set
end
global.poisson_set = {}
function poison_rng_next(l)
if not global.poisson_set[l] then
global.poisson_set[l] = generate_poisson_set(l, 1000)
end
return global.poisson_set[l][math.random(1000)]
end

View File

@ -53,7 +53,7 @@ in this file and your run_*type*_module(event) function will be called.
--ores--
--require "locale.gen_ores.neko_crazy_ores"
--require "locale.gen_ores.fluffy_rainbows"
--require "locale.gen_ores.rso.rso_control"
require "locale.gen_ores.rso.rso_control"
--require "locale.gen_ores.harmonic_gen"
--everything else. You may use more than one of these, but beware they might not be compatible