local noise = require("noise") local tne = noise.to_noise_expression local litexp = noise.literal_expression local seed1 = 1234 local pi_over_3 = tne(math.pi)/3 -- enemy_base_border_width gives the width of the border in which probability ramps up from 0 to 1. -- i.e. slope = 1 / border_width, and height = radius / border_width -- In practice, a probabilty of about 1/9 will result in a solid carpet of biter bases, -- which is why this border width is so high (ignoring blobbiness, most of the inner part of the 'border' would be solid biter bases) local enemy_base_border_width = 9 -- Spots per square meter (should be a very small fraction): local frequency_expression = noise.max(0, noise.var("enemy-base-frequency")) local spot_radius_expression = noise.max(0, noise.var("enemy-base-radius")) -- multiply by spot_radius_expression to keep slope constant: local spot_height_expression = spot_radius_expression / enemy_base_border_width local spot_quantity_expression = pi_over_3 * spot_radius_expression * spot_radius_expression * spot_height_expression -- spot_quantity_expression = noise.compile_time_log("Spot quantity: ", spot_quantity_expression) local density_expression = spot_quantity_expression * frequency_expression -- density_expression = noise.compile_time_log("Density: ", density_expression) local basement_value = -1000 local spots = tne{ type = "function-application", function_name = "spot-noise", arguments = { x = noise.var("x"), y = noise.var("y"), seed0 = noise.var("map_seed"), seed1 = tne(seed1), region_size = tne(1024), candidate_point_count = tne(4), suggested_minimum_candidate_point_spacing = tne(512), density_expression = litexp(pi_over_3 * 256 * 256 * 256 / 8), -- litexp(density_expression), -- low-frequency noise evaluate for an entire region spot_quantity_expression = litexp(pi_over_3 * 256 * 256 * 256 / 8), --litexp(spot_quantity_expression), -- used to figure out where spots go hard_region_target_quantity = tne(false), -- it's fine for large spots to push region quantity past the target spot_radius_expression = litexp(128), spot_favorability_expression = litexp(1), basement_value = tne(basement_value), maximum_spot_basement_radius = tne(256) } } local jitter = tne{ type = "function-application", function_name = "factorio-basis-noise", arguments = { x = noise.var("x"), y = noise.var("y"), seed0 = noise.var("map_seed"), -- i.e. map.seed seed1 = tne(123), -- Some random number input_scale = noise.var("segmentation_multiplier")/20, output_scale = 20/noise.var("segmentation_multiplier") } } data:extend{ { type = "noise-expression", name = "CS-islands", intended_property = "elevation", expression = noise.define_noise_function(function(x, y, tile, map) return tne(spots - 0.1 + jitter / 10000) --noise.spots({x=x, y=y, seed0=map.seed, seed1=0}) end) } } data.raw["map-gen-presets"]["default"].islands = { order = "i", basic_settings = { property_expression_names = { elevation = "CS-islands", }, autoplace_controls = {}, terrain_segmentation = 1, } }