优化

本页面所适用的版本可能已经过时,最后更新于2.7
(重定向自Optimization

Optimization is a set of mechanisms and techniques that ensures that the game performance remains acceptable after hundred years.

The game performance mainly depends on the number of living characters, on whom events need to be processed, and that need to be kept in the save files.[1] The number of characters is itself closely tied to the number of provinces. But it is worth noting that courts are only generated for characters above baron level (except for patricians), so adding more barons has considerably less of an effect on performance than adding more counts.

Pruning

Pruning is the removal of unimportant characters, so that the number of courtiers remains reasonable and game performance acceptable due to events & decisions processed on courtiers.

It balances out the random character generation used to populate courts, since characters may not die naturally as fast as new ones get generated.

Pruned characters are killed with death reason death_vanished, aka "vanished without a trace".

Pruning is controlled by:

  • NDefines.NEngine.COURT_PRUNE_SIZE = 10: courts larger than this will be checked for pruning each month
  • NDefines.NEngine.HEALTH_IMMUNITY_TO_PRUNING = 7: if a character has that much health, they won't be pruned
  • NDefines.NEngine.PRUNE_MINIMAL_AGE = 40
  • Courtiers who have minor titles, friends, lovers, consorts or rivals are excluded
  • Immortal characters are excluded
  • Characters marked as special interest by the player are excluded.

There's also a related scripted trigger used in some mass disease events:

is_unimportant_trigger = {
	NOR = {
		is_married = yes
		is_landed = yes
		has_job_title = yes
		has_minor_title = yes
		AND = {
			NOT = { dynasty = none }
			num_of_dynasty_members = 2
		}
		any_lover = { ai = no }
		any_close_relative = { ai = no }
		any_friend = { ai = no }
		any_rival = { ai = no }
		any_consort = { ai = no }
		num_of_claims = 1
		has_character_flag = eternal_life_mystic
		trait = horse
		has_character_modifier = in_seclusion
		immortal = yes
	}
}

Note that another trigger of pruning is the inheritance of a title: rather than moving all characters of the old court of the title to the court of the new holder, some characters are pruned.

Due to a different behavior,[2] these characters die of death_natural reason and some of the checks above (immortal, ...) are bypassed.

Health Penalty

All unimportant characters(look above) receive health penalty depending on court size.

Court Size Health Penalty
0..9 -1 Health
10..19 -1.5 Health
20..29 -2 Health
30+ -3 Health

Court size is hardcoded but health penalties are governed by parameter

Fertility Penalty

Reduces the number of children characters can have by one. It affect anyone who does not have a close relative that is landed, as long as there are at least 30 people in the court. Governed by NDefines.NCharacter.COURT_SIZE_CHILD_PENALTY_THRESHOLD parameter.

Save compression



Script optimizations



References