Questions regarding mapscript functions

Joined
Jul 31, 2014
Messages
836
With regards to the function FractalWorld:InitFractal in FractalWorld.lua, is anyone familiar with what the argument "continent_grain" represents? I'm vaguely guessing it has something to do with how many continents (or groups of landmasses that are assigned as a "continent") are created? (But then again, the hard-coded numPlates constant controls how many tectonic plates are formed).

----------------------

For the function GenerateCoasts(args), what do the numbers generally represent? I.e. what might increasing the number of elements in the array (i.e. archipelago passes 3 numbers, the default setting is 2 numbers), and increasing the values of the numbers in the arrays do?

For example, archipelago.lua passes

Code:
local args = {expansion_diceroll_table = {10, 4, 4}};

as the local args, which the MapGenerator.lua takes and runs the loop:

Code:
for loop, iExpansionDiceroll in ipairs(expansion_diceroll_table) do
		local shallowWaterPlots = {};
		for i, plot in Plots() do
			if(plot:GetTerrainType() == deepWater) then
				-- Chance for each eligible plot to become an expansion is 1 / iExpansionDiceroll.
				-- Default is two passes at 1/4 chance per eligible plot on each pass.
				if(plot:IsAdjacentToShallowWater() and Map.Rand(iExpansionDiceroll, "add shallows") == 0) then
					table.insert(shallowWaterPlots, plot);
				end
			end
		end
		for i, plot in ipairs(shallowWaterPlots) do
			plot:SetTerrainType(shallowWater, false, false);
		end
	end

Can't seem to wrap my head around what this code block is doing.
 
That code block is adding the "bumps" of coastal water that stick out into the oceans.

By default every water hex next to a land hex is coastal, while every other water hex is ocean. That would leave a 1 tile wide continental shelf around every landmass - somewhat boring.

The GenerateCoasts() function adds "ripples/bumps" to those 1 tile wide shelves.

By default, the test is run twice at 25% (1/4).

For every ocean plot that's next to a coastal plot, roll the percentile dice and if it's less than 25% make the ocean plot coastal.

So on the first pass we can only consider ocean plots two tiles away from land, but depending on the results of the first pass, the second pass will also consider ocean tiles three tiles away from land, if on the first pass its two-tile away neighbour got flipped from ocean to coastal.

So the more numbers in the array, the more passes are done, and hence the possibility of coastal water further from shore.

The SMALLER the numbers, the GREATER the chance of ocean flipping to coastal is.

The ultimate result of adding the extra value into the archipelago map is that there is a chance of longer thin ribbons of coast across oceans joining islands - better for pre-astronomy exploration.
 
As to FractalWorld:InitFractal(), it ultimately calls back into the CvFractal.cpp source file, but the logic/maths in there is beyond me.
 
With regards to the function FractalWorld:InitFractal in FractalWorld.lua, is anyone familiar with what the argument "continent_grain" represents?

For anyone interested, increasing the number of grains basically takes King DeDeDe's hammer and smashes the existing landmasses into little bits and pieces.

Case in point:

Code:
fractal_world:InitFractal{
		continent_grain = 8};

will make Archipelago look like a Tiny Islands map (the default for continent_grain is 4).
 
Back
Top Bottom