mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-03-03 14:53:01 +02:00
Moved poisson rng to utils, fixed a potential nil reference and fixed poison typo
This commit is contained in:
parent
23a78b468e
commit
10d1b0ebe3
@ -1,5 +1,5 @@
|
|||||||
require("locale.gen_combined.grilledham_map_gen.builders")
|
require("locale.gen_combined.grilledham_map_gen.builders")
|
||||||
require("locale.gen_shared.poisson")
|
require("locale.utils.poisson")
|
||||||
|
|
||||||
local Thread = require "locale.utils.Thread"
|
local Thread = require "locale.utils.Thread"
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ function check_decorative(tile, x, y)
|
|||||||
for _,e in ipairs(options) do
|
for _,e in ipairs(options) do
|
||||||
name = e[1]
|
name = e[1]
|
||||||
high_roll = e[2]
|
high_roll = e[2]
|
||||||
if poison_rng_next(high_roll / 2 ) == 1 then
|
if poisson_rng_next(high_roll / 2 ) == 1 then
|
||||||
table.insert(tile_decoratives, {name=name, amount=1, position={x,y}})
|
table.insert(tile_decoratives, {name=name, amount=1, position={x,y}})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -323,11 +323,10 @@ function check_entities(tile, x, y)
|
|||||||
for _,e in ipairs(options) do
|
for _,e in ipairs(options) do
|
||||||
name = e[1]
|
name = e[1]
|
||||||
high_roll = e[2]
|
high_roll = e[2]
|
||||||
if poison_rng_next( high_roll / 2 ) == 1 then
|
if poisson_rng_next( high_roll / 2 ) == 1 then
|
||||||
table.insert(tile_entity_list, {name=name, position={x,y}})
|
table.insert(tile_entity_list, {name=name, position={x,y}})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return tile_entity_list
|
return tile_entity_list
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
--Author: Valansch
|
||||||
|
|
||||||
local function generate_pmf_chart(l)
|
local function generate_pmf_chart(l)
|
||||||
chart = {[0] = math.exp(-l)}
|
chart = {[0] = math.exp(-l)}
|
||||||
for k=1,(l*2 + 1) do
|
for k=1,(l*2 + 1) do
|
||||||
@ -15,13 +17,14 @@ local function generate_poisson_set(l, n) --n defines the resolution
|
|||||||
table.insert(set,x)
|
table.insert(set,x)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
set._n = #set
|
||||||
return set
|
return set
|
||||||
end
|
end
|
||||||
|
|
||||||
global.poisson_set = {}
|
global.poisson_set = {}
|
||||||
function poison_rng_next(l)
|
function poisson_rng_next(l)
|
||||||
if not global.poisson_set[l] then
|
if not global.poisson_set[l] then
|
||||||
global.poisson_set[l] = generate_poisson_set(l, 1000)
|
global.poisson_set[l] = generate_poisson_set(l, 1000)
|
||||||
end
|
end
|
||||||
return global.poisson_set[l][math.random(1000)]
|
return global.poisson_set[l][math.random(global.poisson_set[l]._n)]
|
||||||
end
|
end
|
Loading…
x
Reference in New Issue
Block a user