Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
babe294
Tetrominoes: use shared vanilla_ores_stone ore config
lex Jul 8, 2026
d3feca1
Voronoi: use shared vanilla_ores_stone ore config
lex Jul 8, 2026
c7fc424
Tetrominoes: enforce the 4-ore minimum at map creation
lex Jul 8, 2026
032d702
Voronoi: enforce the 4-ore minimum at map creation
lex Jul 8, 2026
2448123
Derive 3way_ores from x_cross_ores
lex Jul 8, 2026
732f46b
Add ore config test suite
lex Jul 8, 2026
ebf07f4
Danger Ores: add a factory for the standard main-ore configs
lex Jul 8, 2026
d82dd74
Danger Ores: derive vanilla_ores from the main-ores factory
lex Jul 8, 2026
22532c2
Danger Ores: derive vanilla_ores_one_direction from the factory
lex Jul 8, 2026
ab8c633
Danger Ores: derive vanilla_ores_landfill from the factory
lex Jul 8, 2026
c62c175
Danger Ores: derive one_direction_ores_xmas from the factory
lex Jul 8, 2026
325aa7a
Danger Ores: derive x_cross_ores from the factory
lex Jul 8, 2026
b5d9ceb
Danger Ores: derive vanilla_ores_gridlocked from the factory
lex Jul 8, 2026
72708e0
Danger Ores: derive joker_starter_area from the factory
lex Jul 8, 2026
54e1694
Danger Ores: derive poor_mans_coal_fields_ores from the factory
lex Jul 8, 2026
cead7e5
Danger Ores: build the vanilla_ores_stone stone entry via the factory
lex Jul 8, 2026
dd7f5e0
Danger Ores: cover the main-ores factory in the config test suite
lex Jul 8, 2026
e6740b5
Danger Ores: silence unused stub argument in ore config tests
lex Jul 8, 2026
2925479
Danger Ores: fold the coal-rich mix into the canonical coal mix
lex Jul 9, 2026
4f86de2
Danger Ores: standardize richness curves on the vanilla pair
lex Jul 9, 2026
06e1dd2
Danger Ores: retire the redundant ore config files
lex Jul 9, 2026
76b2bee
Danger Ores: joker starter coal joins the standard richness budget
lex Jul 9, 2026
d751371
Danger Ores: fluent API for the main-ores factory
lex Jul 9, 2026
69bbe6c
Danger Ores: express the standard configs through the fluent API
lex Jul 9, 2026
ac71c95
Danger Ores: complete the fluent API, use utils.table's deep_copy
lex Jul 9, 2026
2491ec8
Danger Ores: restore the Joker starter's low coal budget
lex Jul 9, 2026
ea42815
Danger Ores: xmas tree keeps default tiles minus grass-4
lex Jul 9, 2026
b5806cf
Danger Ores: add :change_mix to the fluent API
lex Jul 9, 2026
912bf06
Danger Ores: express the all-coal config through the fluent API
lex Jul 9, 2026
a6b31ea
Danger Ores: express the scrap config through the fluent API
lex Jul 9, 2026
ab6a01c
Danger Ores: named arguments for the fluent curve shorthands
lex Jul 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 0 additions & 76 deletions map_gen/maps/danger_ores/config/3way_ores.lua

This file was deleted.

102 changes: 20 additions & 82 deletions map_gen/maps/danger_ores/config/joker_starter_area.lua
Original file line number Diff line number Diff line change
@@ -1,92 +1,30 @@
-- The Joker starter area: canonical mixes with time-budgeted richness -- each patch
-- holds roughly a day of a single electric mining drill's output. Plus a token
-- super-rich uranium entry.
local b = require 'map_gen.shared.builders'
local Factory = require 'map_gen.maps.danger_ores.config.main_ores_factory'

local mine_speed = 0.5 / 10 -- 0.5 ore/s per electric mining drill
local low = 60 * 60 * 4 * mine_speed -- 4h
Comment thread
RedRafe marked this conversation as resolved.
local medium = 60 * 60 * 24 * mine_speed -- 24h

local low_value = b.exponential_value(low, 0.07, 1.45)
local medium_value = b.exponential_value(medium, 0.07, 1.45)

return {
{
name = 'copper-ore',
tiles = {
[1] = 'red-desert-0',
[2] = 'red-desert-1',
[3] = 'red-desert-2',
[4] = 'red-desert-3'
},
start = 1,
weight = 1,
ratios = {
{resource = b.resource(b.full_shape, 'iron-ore', medium_value), weight = 15},
{resource = b.resource(b.full_shape, 'copper-ore', medium_value), weight = 70},
{resource = b.resource(b.full_shape, 'stone', medium_value), weight = 10},
{resource = b.resource(b.full_shape, 'coal', medium_value), weight = 5}
}
},
{
name = 'coal',
tiles = {
[1] = 'dirt-1',
[2] = 'dirt-2',
[3] = 'dirt-3',
[4] = 'dirt-4',
[5] = 'dirt-5',
[6] = 'dirt-6',
[7] = 'dirt-7'
},
start = 1,
weight = 1,
ratios = {
{resource = b.resource(b.full_shape, 'iron-ore', low_value), weight = 18},
{resource = b.resource(b.full_shape, 'copper-ore', low_value), weight = 9},
{resource = b.resource(b.full_shape, 'stone', low_value), weight = 8},
{resource = b.resource(b.full_shape, 'coal', low_value), weight = 65}
}
},
{
name = 'iron-ore',
tiles = {
[1] = 'grass-1',
[2] = 'grass-2',
[3] = 'grass-3',
[4] = 'grass-4'
},
start = 1,
weight = 1,
ratios = {
{resource = b.resource(b.full_shape, 'iron-ore', medium_value), weight = 75},
{resource = b.resource(b.full_shape, 'copper-ore', medium_value), weight = 13},
{resource = b.resource(b.full_shape, 'stone', medium_value), weight = 7},
{resource = b.resource(b.full_shape, 'coal', medium_value), weight = 5}
}
},
{
name = 'stone',
tiles = {
[1] = 'sand-1',
[2] = 'sand-2',
[3] = 'sand-3'
},
start = 1,
weight = 1,
ratios = {
{resource = b.resource(b.full_shape, 'iron-ore', medium_value), weight = 25},
{resource = b.resource(b.full_shape, 'copper-ore', medium_value), weight = 10},
{resource = b.resource(b.full_shape, 'stone', medium_value), weight = 60},
{resource = b.resource(b.full_shape, 'coal', medium_value), weight = 5}
}
},
{
name = 'uranium-ore',
start = 1,
weight = 1,
ratios = {
{
resource = b.resource(b.full_shape, 'uranium-ore', function() return 1e6 end),
weight = 1
},
local config = Factory.main_ores {
ores = {'copper-ore', 'coal', 'iron-ore', 'stone'},
start = 1,
value = medium_value
}

config[#config + 1] = {
name = 'uranium-ore',
start = 1,
weight = 1,
ratios = {
{
resource = b.resource(b.full_shape, 'uranium-ore', function() return 1e6 end),
weight = 1
}
}
}

return config
95 changes: 95 additions & 0 deletions map_gen/maps/danger_ores/config/main_ores_factory.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
-- Factory for the standard danger-ores main-ore configs. Most of them use the same
-- per-ore floor tiles and the same dominant+minor resource mixes, differing only in
-- richness curves, ore order, entry weights or tile skins. This module holds those
-- canonical numbers once; each config composes its entries from here.
local b = require 'map_gen.shared.builders'

local Public = {}

-- Per-ore floor tiles.
local tile_sets = {
['iron-ore'] = {'grass-1', 'grass-2', 'grass-3', 'grass-4'},
['copper-ore'] = {'red-desert-0', 'red-desert-1', 'red-desert-2', 'red-desert-3'},
['coal'] = {'dirt-1', 'dirt-2', 'dirt-3', 'dirt-4', 'dirt-5', 'dirt-6', 'dirt-7'},
['stone'] = {'sand-1', 'sand-2', 'sand-3'}
}

-- Dominant + minor mixes as {resource name, ratio weight} pairs, in canonical order.
local mixes = {
['iron-ore'] = {{'iron-ore', 75}, {'copper-ore', 13}, {'stone', 7}, {'coal', 5}},
['copper-ore'] = {{'iron-ore', 15}, {'copper-ore', 70}, {'stone', 10}, {'coal', 5}},
['coal'] = {{'iron-ore', 18}, {'copper-ore', 9}, {'stone', 8}, {'coal', 65}},
['stone'] = {{'iron-ore', 25}, {'copper-ore', 10}, {'stone', 60}, {'coal', 5}}
}
Public.mixes = mixes

local function copy_array(array)
local copy = {}
for i, v in ipairs(array) do
copy[i] = v
end
return copy
end
Comment thread
RedRafe marked this conversation as resolved.
Outdated

-- Fresh copy per call: the runtime must never share mutable tables between entries.
function Public.tiles(ore_name)
return copy_array(tile_sets[ore_name])
end

-- Build a ratios table from a mix. make_resource(resource_name) -> resource shape.
function Public.ratios(mix_name, make_resource)
local ratios = {}
for i, mix in ipairs(mixes[mix_name]) do
ratios[i] = {resource = make_resource(mix[1]), weight = mix[2]}
end
return ratios
end

-- The common case: plain full-shape resources with one richness curve.
function Public.full_shape_resource(value)
return function(resource_name)
return b.resource(b.full_shape, resource_name, value)
end
end

-- One main-ore entry. params: name (required), start (required), and either value or
-- make_resource; mix (defaults to name), tiles (defaults to the ore's tile set) and
-- weight (defaults to 1) optional.
function Public.entry(params)
local name = params.name
local make_resource = params.make_resource
if not make_resource then
assert(params.value, 'main_ores_factory.entry: either value or make_resource is required')
make_resource = Public.full_shape_resource(params.value)
end
return {
name = name,
tiles = params.tiles or Public.tiles(name),
start = params.start,
weight = params.weight or 1,
ratios = Public.ratios(params.mix or name, make_resource)
}
end

-- A whole main-ores config in one call. ores is an array of ore names or per-entry
-- params tables; start/value/weight/tiles/make_resource act as defaults for every entry.
function Public.main_ores(params)
local config = {}
for i, ore in ipairs(params.ores) do
if type(ore) == 'string' then
ore = {name = ore}
end
config[i] = Public.entry {
name = ore.name,
mix = ore.mix,
tiles = ore.tiles or (params.tiles and copy_array(params.tiles)),
start = ore.start or params.start,
value = ore.value or params.value,
weight = ore.weight or params.weight,
make_resource = ore.make_resource or params.make_resource
}
end
return config
end

return Public
74 changes: 0 additions & 74 deletions map_gen/maps/danger_ores/config/one_direction_ores_xmas.lua

This file was deleted.

Loading
Loading