Page 1 of 1

How much food do I need to produce a new population?

Posted: Sun Jul 12, 2020 1:33 am
by duirixuanyan
It seems simple.
30
45
60
75
90
105
120
135
150

However, some regions say no.
225
263
255
301
351
202

I'm really confused.

Re: How much food do I need to produce a new population?

Posted: Sun Jul 12, 2020 9:38 am
by Surt
Hmm, now you made me confused too!!!

Plain (heatwave)
Cyrenaica, pop 32, needs 1297 food, bonus 47% = 1150 discount (sum 2447)
Arid steppes:
Arsinoe, pop 28, needs 2839 food, bonus 33% = 1399 discount (sum 4238)
Syrtica, pop 28, needs 3204 food, bonus 58% = 4424 discount (sum 7628)

Re: How much food do I need to produce a new population?

Posted: Sun Jul 12, 2020 4:35 pm
by Gray Fox
Is this a reflection of regions in a province pooling their food? Supposedly, all the regions must grow to size X before any one grows to X+1.

Re: How much food do I need to produce a new population?

Posted: Sun Jul 12, 2020 6:07 pm
by Swuul
It depends on the terrain in the region and how many people you already have in the region. If you go above the hard-cap max for the region, it starts to become rather impossible to get more pop from surplus food. For example 2 POP in Plains vs 20 POP in Desert, the required food for extra pop is quite different :)

Re: How much food do I need to produce a new population?

Posted: Sun Jul 12, 2020 8:23 pm
by Surt
Arsinoe and Syrtica are same terrain, both coastal, Arsinoe is the regional capital though.

Re: How much food do I need to produce a new population?

Posted: Mon Jul 13, 2020 9:35 am
by Pocus
starting population fixes the soft-limit of population growth. Past this soft limit, you get extra cost penalties to grow pop

Re: How much food do I need to produce a new population?

Posted: Tue Jul 14, 2020 10:37 am
by duirixuanyan
Pocus wrote: Mon Jul 13, 2020 9:35 am starting population fixes the soft-limit of population growth. Past this soft limit, you get extra cost penalties to grow pop
What is the the soft-limit if the starting population is 1?

Re: How much food do I need to produce a new population?

Posted: Tue Jul 14, 2020 9:24 pm
by n0b0dy007
It's in Region.bsf/Region_Population_FoodNeedNextGrowth().
Basically:

Code: Select all

popCount = Region_Population_Count(regionID);
	// The function is exponential but we are not using a power function, too nerdy to explain in the manual?
	if (popCount >= 30)
	{
		coeff = (popCount - 13) * 4 // pop 30: x68 | pop 31: x72 | pop 32: x76
	}
	else if (popCount >= 20)
	{
		coeff = (popCount - 8) * 3 // pop 20: x36 | pop 21: x39 | pop 22: x42 |..| pop 29: x63
	}
	else if (popCount >= 10)
	{
		coeff = (popCount - 2) * 2 // pop 10: x16 | pop 11: x18 | pop 12: x20 |..| pop 19: x34
	}
	else
	{
		coeff = POP_NEED_FOOD_PERPOP; // 15
	}
	result = POP_BASE_NEED_FOOD + (coeff * popCount);
plus some other factors.

Re: How much food do I need to produce a new population?

Posted: Wed Jul 15, 2020 10:36 am
by duirixuanyan
Thanks a lot.

Code: Select all

	// If beyond x time the initial number of inhabitants, penalize heavily
	count = GetNumPopulations(regionID) * 100 ;
	count = DivideAndRound(count, Max(POP_FOOD_POPULOUS_MINVAL, Region_Population_GetInitialInhabitants(regionID)));
	count -= POP_FOOD_POPULOUS_RATIOh;
	coeff = 100;
	while (count >= 0)
	{
		coeff += POP_FOOD_POPULOUS_COEFF;
		count -= 100;
	}
	result = DivideAndRound(result * coeff, 100); 

I don't understand this part. Could you explain it?
For example, popCount=53, result = POP_BASE_NEED_FOOD + (coeff * popCount)=8495.
result = DivideAndRound(result * coeff, 100)=72208, meaning coeff=8.5

I don't know what these numbers are.
POP_FOOD_POPULOUS_MINVAL,POP_FOOD_POPULOUS_RATIOh,POP_FOOD_POPULOUS_COEFF

Re: How much food do I need to produce a new population?

Posted: Wed Jul 15, 2020 1:16 pm
by n0b0dy007
duirixuanyan wrote: Wed Jul 15, 2020 10:36 am I don't know what these numbers are.
POP_FOOD_POPULOUS_MINVAL,POP_FOOD_POPULOUS_RATIOh,POP_FOOD_POPULOUS_COEFF
These are constants defined in MapGlobals.bsf. A few have some commentary hints:

Code: Select all

// *** P_ ***
// __POPULATION
#define POP_REALNUMBERCOEFF 10000
#define POP_BASE_NEED_FOOD 15
#define POP_NEED_FOOD_PERPOP 15
#define POP_FOOD_USAGE_SLAVE 1
#define POP_FOOD_USAGE_OTHER 2
#define POP_HEALTH_MAX_BONUS 65 // no more than 65% discount in food need from health
#define POP_HEALTH_MAX_PENALTY -300 // no more than -300% penalty in food need from health
#define POP_KEEP_FOOD_PERC 15 // keep 15% of food on growth
#define POP_COEFF_GROWTH_WF 4 // slowdown coeff on pop growth for world faction (also used in infra bld)
#define POP_FOOD_POPULOUS_COEFF 50 // +50% food cost per pop ratio at populous and beyond
#define POP_FOOD_POPULOUS_RATIOh 300 // starting ratio where you get a penalty (in hundredth)
#define POP_FOOD_POPULOUS_MINVAL 3 // Min pop ever considered, preserve some back compatibility
duirixuanyan wrote: Wed Jul 15, 2020 10:36 am I don't understand this part. Could you explain it?
I don't understand it, either, as the software's design description is not available. It's apparently an implementation of some game rule's logic.

Philippe, as the code's author, can probably explain his intent.

Re: How much food do I need to produce a new population?

Posted: Wed Jul 15, 2020 5:58 pm
by Surt
Nice, so most of the game is in the .bsf files!!!

Re: How much food do I need to produce a new population?

Posted: Wed Jul 15, 2020 7:45 pm
by n0b0dy007
Surt wrote: Wed Jul 15, 2020 5:58 pm Nice, so most of the game is in the .bsf files!!!
Pretty much. The rules/logic and UI code, anyway. The data live in the DATA directory's .csv files (generated from the .xlsx spreadsheets, per: viewtopic.php?f=562&t=99539).
The BSF files are text files containing CScript code, which is Slitherine's C-like dialect for their Archon engine (see: viewtopic.php?f=562&t=93020 and http://archonwiki.slitherine.com/index. ... es_Modding).
The Archon engine is 32-bit and single-threaded, so set expectations accordingly.

It also appears that the contents of Data/ATTRIBUTES.TXT (crucially, the main data structures and their attributes) serve as input to a process that generates the API found in AUTODOCS/BATTLESCRIPT.TXT, which serves as the foundational API between the game and the underlying Archon engine. The game's scripts apparently are run through the AUTODOCS/BATTLESCRIPT.BIN interpreter layer.
For some reason (probably a Development setting left on for the Release build :roll: ) the AUTODOCS files are re-generated every time the launcher starts the game.

The attached .zip file contains ARCHON.XML, a file that teaches Notepad++ (https://notepad-plus-plus.org/) about the CScript syntax (the semantics definition, alas, remains elusive).
Although, just setting Language to C works well enough.

Re: How much food do I need to produce a new population?

Posted: Fri Jul 17, 2020 2:45 pm
by Pocus
The idea is that past a certain initial value (thrice the initial population count (A) or 3 (B), whichever is the max), you get an increase of +50% to the found need (C)

(A) #define POP_FOOD_POPULOUS_RATIOh 300 // starting ratio where you get a penalty (in hundredth)
(B) #define POP_FOOD_POPULOUS_MINVAL 3 // Min pop ever considered, preserve some back compatibility
(C) #define POP_FOOD_POPULOUS_COEFF 50 // +50% food cost per pop ratio at populous and beyond