﻿NAI = {
	SHORT_TASK_TICK = {									# Number of days between recalculating short  tasks (per tier)
		7
		30
		14
		7
		7
		7
	}
	
	MEDIUM_TASK_TICK = {								# Number of days between recalculating medium tasks (per tier)
		30
		180
		60
		30
		30
		30
	}
	
	LONG_TASK_TICK = {									# Number of days between recalculating long tasks (per tier)
		60
		360
		180
		60
		60
		60
	}
	
	RARE_TASK_TICK = {									# Number of days between recalculating rare tasks (per tier)
		180
		720
		360
		180
		180
		180
	}

	TITLE_AND_VASSAL_GRANT_TICK = {						# Number of days between checking title and vassal grants (per tier). If a grant happens, it'll always get rechecked on the next day
		720
		720
		720
		90
		90
		90
	}

	REVOKE_TITLE_TICK = {						# Number of days between checking title revocations (per tier). If a revocation happens, it'll always get rechecked on the next day. Imprisoning a vassal will also cause a check on the next day
		720
		720
		720
		360
		360
		360
	}

	MINIMUM_TASKS_IN_TICK = 128							# How many tasks do we need in each tick?
	MAX_TASKS_IN_TICK = 192								# How high do we cap out? (If the frequency of a tick means we should do even more than this, we ignore this)
	MAX_TICK_STALENESS = 10								# How long can we delay a tick for better load-balancing?

	BUDGET_CATEGORY = {									# The last category is the main category
		0.0												# Reserved (only used for certain types of characters, like the Pope)
		0.0												# War chest; has its own logic
		0.25											# LongTerm
		0.75											# ShortTerm
	}
	
	BUDGET_CATEGORY_MAX = {								# Over max it will try to redistribute overflow to other category
		-1
		-1
		5000
		5000
	}
	
	BUDGET_CATEGORY_SHORT_TERM_MIN = {					# Under this amount of short term gold the AI will be hesitant to spend/save on other categories (per tier)
		50
		50
		100
		200
		400
		6000
	}
	
	MIN_RESERVED_GOLD_SPIRITUAL_HEAD_OF_FAITH = 750		# Character will avoid actively using gold if under this value
	MIN_RESERVED_GOLD_HOLY_ORDER = 500					# Character will avoid actively using gold if under this value
	MIN_WAR_CHEST = {									# The desired war chest will always be at least this much money, by tier
		50
		50
		100
		200
		400
		600
	}
	MONTHS_OF_MAINTENANCE_IN_WAR_CHEST = 24				# The AI will want this many months of max maintenance in their war chest, if that's more than what MIN_WAR_CHEST says
	PERCENTAGE_INTO_WAR_CHEST = 0.75					# When the war chest hasn't been filled, the AI will put this much of the money it earns into the war chest (reserved gold still gets filled first)
	BUILDING_MIN_SCORE_COMPARED_TO_BEST = 0.8			# Any potential building with a score lower than this ratio of the best available building (even if the AI can't afford it right now) will be discarded
	
	GOALS_PER_TYPE = {									# Number goals per type (per tier)
		0
		0
		1
		2
		3
		3
	}

	MEN_AT_ARMS_EXPENSE_GOAL = 0.4						# The AI will try to spend this much of its income on MAA maintenance
	MEN_AT_ARMS_EXPENSE_MAX = 0.6						# The AI will disband MAA if it ends up spending more than this amount of its income on maintenance

	MEN_AT_ARMS_PRESTIGE_EXPENSE_GOAL = 0.4				# The AI will try to spend this much of its prestige income on MAA maintenance
	MEN_AT_ARMS_PRESTIGE_EXPENSE_MAX = 0.6				# The AI will disband MAA if it ends up spending more than this amount of its prestige income on maintenance
	MEN_AT_ARMS_CHANCE_EXPENSE_ZERO = 1					# Chance the AI will prefer MaA to buildings when spending nothing on MaA
	MEN_AT_ARMS_CHANCE_EXPENSE_MIN = 0.2				# Chance the AI will prefer MaA to buildings when spending the goal amount on MaA. For values between that and zero, we interpolate
	MEN_AT_ARMS_REALM_SIZE_FOR_COST_EFFECTIVENESS_START = 5	# At realm sizes of this and below, men at arms quality is based on stat points compared to cost
	MEN_AT_ARMS_REALM_SIZE_FOR_COST_EFFECTIVENESS_END = 50	# At realm sizes after this, men at arms quality is completely unaffected by cost. Between the two values, we interpolate between the unmodified and modified quality

	GOAL_MIN_PROGRESS_TO_START = 0.2					# Resources needed to be able to add a goal
	
	GOAL_CREATE_TITLE_TIER_SCORE = 100					# Multiplied by tier * tier
	GOAL_CREATE_TITLE_DE_JURE_MULTIPLIER = 1.5			# If de jure under the character
	
	CHARACTER_INTERACTION_DEFAULT_MIN_REPLY_DAYS = 3	# the AI will wait at least this many days before replying to a character interaction the interaction can override this value
	CHARACTER_INTERACTION_DEFAULT_MAX_REPLY_DAYS = 10	# the AI will wait at most this many days before replying to a character interaction the interaction can override this value
	
	BETROTHAL_MIN_AGE = 12								# The AI will not betrothe, nor seek betrothals with characters under this age.
	MARRIAGE_FOCUS_MIN_AGE = 20							# Under this age the AI will less often check for betrothals/mariiages
	
	MARRIAGE_MALE_DESPERATION_AGE = 25					# Over this age the AI will consider less enticing marriages
	MARRIAGE_FEMALE_DESPERATION_AGE = 25				# Over this age the AI will consider less enticing marriages
	MARRIAGE_DESPERATION_AGE_MULTIPLIER = 50			# Multiplied with age minus desperation age
	MARRIAGE_NO_PRESTIGE_LOSS_BONUS = 50				# If a marriage causes no prestige loss, a bit of score is added
	
	MAX_NUMBER_OF_COURTS_TO_SEARCH_FOR_SPOUSES = {		# Number of courts that are searched for spouse candidates, per tier.
		0
		0
		8
		16
		32
		32
	}
	
	MAX_NUMBER_OF_SPOUSE_CANDIDATES = {					# Number of spouse candidates before the search is aborted, per tier.
		0
		0
		4
		8
		16
		32
	}
	
	SPOUSE_SCORE_ALLIANCES_WANTED = 2					# Over this number, new alliances through marriage will not impact spouse score unless they are of a higher tier than the current highest tier alliance
	SPOUSE_SCORE_EXISTING_ALLIANCE_DIVIDER = 2			# If already allied, divide the alliance score with this
	
	SPOUSE_SCORE_HIGHER_TIER_ALLIANCE = 1000			# Score if the marriage yields an alliance with a higher-tier character
	SPOUSE_SCORE_SAME_TIER_ALLIANCE = 500				# Score if the marriage yields an alliance with a same-tier character
	SPOUSE_SCORE_LOWER_TIER_ALLIANCE = 100				# Score if the marriage yields an alliance with a lower-tier character
	
	SPOUSE_SCORE_MALE_AGE_PENALTY_AGE = 50				# Over this age a male spouse score penalty is applied
	SPOUSE_SCORE_FEMALE_AGE_PENALTY_AGE = 30			# Over this age a female spouse score penalty is applied
	SPOUSE_SCORE_MALE_AGE_PENALTY_MULTIPLIER = 10		# Multiplied with male spouse's age above SPOUSE_SCORE_MALE_AGE_PENALTY_AGE
	SPOUSE_SCORE_FEMALE_AGE_PENALTY_MULTIPLIER = 10		# Multiplied with female spouse's age above SPOUSE_SCORE_FEMALE_AGE_PENALTY_AGE
	
	THREAT_MIN_STRENGTH_RATIO = 0.5						# Only consider threats above this ratio
	THREAT_CLAIM_TIER_MULTIPLIER = 10					# Multiplied with each claim's tier squared
	THREAT_DE_JURE_CLAIM_MULTIPLIER = 50				# Multiplied de jure claim
	THREAT_MAX_DIPLO_DISTANCE = 1000					# Max distance to be considered a threat
	THREAT_STRENGTH_NEIGHBOUR_RATIO_MULTIPLIER = 100	# Multiplied with the strengt ratio
	THREAT_STRENGTH_RATIO_MULTIPLIER = 50				# Multiplied with the strengt ratio

	ENEMY_MAX_STRENGTH_MULTIPLIER = 1.5					# Only consider enemies equal or below this ratio
	ENEMY_CLAIM_TIER_MULTIPLIER = 10					# Multiplied with each claim's tier squared
	ENEMY_DE_JURE_CLAIM_MULTIPLIER = 50					# Multiplied de jure claim
	
	FRIEND_ALLY_MAX_DIPLO_DISTANCE = 1000				# Max distance to be considered for a strength ratio bonus
	FRIEND_ALLY_MIN_STRENGTH_RATIO = 0.25				# Only add strength ratio bonus for equal or above this ratio
	FRIEND_ALLY_STRENGTH_RATIO_MULTIPLIER = 100			# Multiplied with the strengt ratio
	
	MAX_NUMBER_OF_DIPLO_VALUES = {						# Number of allowed entries in each category (per tier)
		0
		2
		4
		6
		8
		10
	}
	
	MURDER_BASE_CHANCE = 10								# Chance of the AI starting a murder scheme against a valid target
	PLAYER_INTERACTION_REJECTION_DELAY_MONTHS = 12		# The AI isn't allowed to resend a rejected interaction until this many months have passed
	
	MIN_PATH_COST_TO_CONSIDER_WATER_PATH = 120			# Number of travel days before AI considers searching for a path across water instead
	MIN_PATH_COST_SAVINGS_TO_CONSIDER_WATER_PATH = 65	# Number of travel days saved before AI considers going through water instead
	
	MAX_PATH_COST_FACTOR = 5							# The maximum cost for a path is this factor times the straight path cost
	
	RAISE_LEVIES_COOLDOWN = 180							# Number of days before the AI tries to raise levies if it already has an army
	RAISE_TROOPS_MIN_RATIO_OF_SELF = 0.3				# If the AI doesn't have troops raised, it won't raise them unless the troops amount to at least this much compared to its max troops
	RAISE_TROOPS_MIN_RATIO_OF_ENEMY = 0.5				# Or this much compared to its enemy
	REDUCED_EFFECTIVE_WEALTH_PER_HIRED_MERC = 100		# For each hired merc, the AI pretends to have less money so that it ends up keeping some reserves
	MIN_HIRING_GOAL = 500								# If missing less than this amount to outnumber its enemies, the AI will hire as if were actually missing this amount
	MAX_HIRING_GOAL_OVERFLOW_RATIO = 2					# The AI won't hire more than this times as many men as it is missing. It'll hire the most expensive merc that fits within this. E.G., this means that if the AI is missing 1000 men, it'll hire the most expensive merc with less than 2000 men
	MONTHS_BEFORE_CONTRACT_END_TO_REHIRE = 3			# This many months before a merc contract ends, the AI will rehire mercs if it can afford it and thinks it still needs them

	TITLE_GRANT_HATE_THRESHOLD = -25					# The AI will mostly avoid giving titles to people whose opinion of them is below this
	TITLE_GRANT_VASSAL_CHILD_SUCCESSION_DISTANCE = 3	# The AI will give titles to the children of vassal sometimes if they're the xth child (ignoring those of a non-preferred gender), and not in line to inherit anything
	COUNCIL_TASK_SWITCH_SCORE = 1.25					# In order for the AI to switch to a different task type, the task needs to have a score that's at least the score of the current task multiplied with this. 1.25 means it needs to be 25% higher

	# When buying/disbanding MaA, these mults are used to figure out the score. Note that the score is divided by cost, and multiplied by stack size (except for siege value, which is only divided by cost)
	TOUGHNESS_SCORE_MULT = 10
	ATTACK_SCORE_MULT = 10
	PURSUIT_SCORE_MULT = 2
	SCREEN_SCORE_MULT = 1
	SIEGE_VALUE_SCORE_MULT = 1000
	NEGATIVE_SCORE_PER_EXISTING_REGIMENT = 20			# How much is the score of the regiment type reduced per existing subregiment of that type?
	RANDOM_REGIMENT_SCORE_MAX = 0.2						# How much extra score can the AI randomly give to this regiment? Will always be the same for the same character + regiment. 0.2 means 0-20% extra
	NORMAL_SUB_REGIMENTS_PER_SIEGE_SUB_REGIMENT = 5		# How many non-siege regiments should there be for each siege regiment? Siege will always be the first sub-regiment purchased, and the AI will maintain this ratio
	SUBTRACT_NORMAL_SUB_REGIMENTS_FOR_SIEGE_PURPOSES = 3# Ignore this many normal regiments when buying siege sub-regiments. This effectively means the AI will buy their first siege weapon after this many normal ones, and then one more for every NORMAL_SUB_REGIMENTS_PER_SIEGE_SUB_REGIMENT additional normal sub-regiments
	REGIMENT_OBSOLETION_SCORE_DIFFERENCE = 20			# The AI will disband a regiment if it is this much worse than the best available regiment, and it is unable to hire more regiments (due to cost or being at cap). Quick math: 10 damage * 100 men / 200 cost = 5 score difference


	AI_BASE_WAR_CHANCE = 0.4							# Basic chance of declaring war. Further reduced by energy; x0 at -100, x1 at 100, x0.5 at 0 energy
	AI_WAR_BASE_COOLDOWN = 365							# How long, in days, does the AI have to wait between wars?
	AI_WAR_COOLDOWN_RATIO_FOR_FULL_CHANCE = 3			# How far beyond the cooldown do you have to go before the time since the last war stops reducing the chance? With these numbers, chance at day 3650 would be 0x, 1x at 3650*2, and 0.5x at 3650*1.5
	AI_WAR_MAX_OFFENSIVE_WAR_PENALTY = 0.0				# If your offensive war penalty is higher than this, don't declare war unless you're a warmonger (faith doctrine) or irrational
	AI_WAR_MIN_RATIONALITY_FOR_OFFENSIVE_WAR_PENALTY = -30	# At or below this value, the AI will declare war even if their offensive war penalty is high
	MIN_SCORE_RATIO_FOR_CASUS_BELLI = 0.6				# The AI will never declare a war below this ratio of the best war it has available
	EXTRA_CB_SCORE_FOR_HOLY_SITES = 25					# The AI will assign this much extra score to conquering a province that is its holy site
	
	TARGET_MAX_DEFENSIVE_WARS = 3						# AI won't declare war on someone who already has this many or more defensive wars
	DESIRED_WAR_SIDE_STRENGTH = 2.0						# AI won't call in more allies if its side in a war has at least this ratio of troops compared to the enemy. Uses current strength for own side, max strength for enemy side
	
	ENEMY_COMBAT_STRENGTH_MULTIPLIER = 1.1				# The AI will take its estimated enemy strength times this multiplier
	COUNTER_RAID_MIN_DISTANCE = 75						# The AI will try to raise counter-raid troops at least this far awy from the raid
	COUNTER_RAID_MAX_DISTANCE = 200						# The AI will raise counter-raid troops at most this far away from the raid
	OTHER_RAID_ARMY_COMBINED_STRENGTH_MAX_DISTANCE = 200	# Other raid armies no more than this far away will be considered as part of the same raid army for strength purposes
	VASSAL_COUNTER_RAID_MIN_STRENGTH_RATIO = 0.9		# A vassal at least this strong as the raid will be responsible for countering it
	INDEPENDENT_COUNTER_RAID_MIN_STRENGTH_RATIO = 0.6	# An independent ruler at least this strong as the raid will be responsible for countering it if no vassal does
	MAX_RAID_DISTANCE = 1500							# How far away will the AI raid?
	MAX_RAID_DISTANCE_NEXT_COUNTY = 200					# After raiding one county, how far is the AI willing to go to the next?
	MIN_STRENGTH_TO_RAID_VASSAL = 500					# How strong do vassals have to be for the AI to go raiding?
	MIN_STRENGTH_TO_RAID_INDEPENDENT = 300				# How strong do independent rulers have to be for the AI to go raiding?
	MAX_RAID_TARGET_STRENGTH = 1.5						# Don't raid enemies too strong
	MAX_RAID_TARGET_STRENGTH_AT_WAR = 5.0				# But if they're at war, the risk might be worth it
	MIN_STRENGTH_FOR_RAIDER_TO_AVOID = 0.9				# If there's hostile units in this county and neighboring counties that are combined this strong compared to the raid army, flee home
	RAID_SCORE_MIN_STRENGTH_RATIO = 0.2 				# We divide the score by how strong the target is compared to us; if lower than this, we use this number. So 0.2 means that outnumbering them 5:1 and 2:1 are equivalent
	RAID_SCORE_DISTANCE_OFFSET = 200 					# We divide the score by the distance from the realm (or army, if follow-up raid) plus this number
	RAID_SCORE_DISTANCE_OFFSET_NEXT_TARGET = 30 		# We divide the score by the distance from the army plus this number when finding the next county to go to
	RAID_SCORE_FORT_LEVEL_OFFSET = 5 					# We divide the score by the sum of all fort levels in the county, plus this number
	MIN_RAID_SCORE_COMPARED_TO_BEST_SCORE = 0.4			# Scores this much worse than the best score are just discarded
	RAID_CHANCE_AT_MAX_GREED = 0.9						# Chance to go raiding each year if at 100 greed. 0.0 at -100 greed. Must still meet all other conditions
	MAX_RAID_DAYS = 365									# After this long, the AI will go home when a raid action concludes
	RAID_COOLDOWN_DAYS = 1825							# The AI won't start a new day for this long after last having started one
	COUNTER_RAID_COOLDOWN_DAYS = 180					# The AI won't counter-raid for this long after they last counter-raided

	# Hostility levels start at 0 (same faith or equivalent to same faith)
	RAID_SCORE_FAITH_HOSTILITY_MULT = {	# Raid score mult based on hostility
		1
		1.5
		2
		3
	}
	RAID_SCORE_MULT_SAME_CULTURE = 0.5
	RAID_SCORE_MULT_SAME_CULTURE_GROUP = 0.75
	
	CHASE_MIN_SIZE = 100								# The AI will not bother trying to chase armies smaller than this
	# The AI will only retreat if the following are true:
	# It predicts it'll lose according to RETREAT_COMBAT_PREDICTION_RATIO
	# AND it either has significant forces elsewhere, or there's a better defensive location nearby as defined by RETREAT_TO_BETTER_TERRAIN_DISTANCE
	RETREAT_COMBAT_PREDICTION_RATIO = 0.45				# Below this combat prediction ratio the AI will retreat
	RETREAT_TO_BETTER_TERRAIN_DISTANCE = 2				# The AI will retreat to better terrain this many provinces away (might do another retreat once it gets there)
	RETREAT_IF_MISSING_STRENGTH = 0.25					# The AI will retreat if it has this many troops elsewhere compared to the potentially retreating army. E.G., if 2000 men are considered for retreat, it'll do so if there's at least 0.25 * 2000 = 500 men elsewhere
	STAND_AND_FIGHT_DAYS = 30							# If the AI decides to stand still so the other party can kill it on defensible terrain, it'll start doing regular orders again after this many days if death is not forthcoming
	STAND_AND_FIGHT_COOLDOWN_DAYS = 90					# If the AI abandons "stand and fight" due to the above, it'll avoid "stand and fight" for this many days
	DISCARD_UNIT_GOALS_UNDER_TRESHOLD = 0.5				# The AI will discard potential targets scored at this threshold or lower compared to the best target, even if the best target is unsafe
	MIN_GOALS_PER_STACK = 5								# However, it will ensure it always evaluates at least this many goals per stack, even if they're below the threshold
	MIN_SUPPLY_COMPARED_TO_AVERAGE_SUPPLY_FACTOR = 0.7	# For the purpose of army sizes, the AI uses the highest of this factor times the average supply in the war area, and the lowest supply in the war area. E.G., if average supply is 2k, and lowest supply is 1k, the AI will act as if available supply is 0.7 * 2k = 1.4k. But if the lowest supply was 1.5k, it'd be using that instead
	RESUPPLY_MAX_DISTANCE = 3							# How far out can splinters of the army spread when trying to resupply? In # of provinces. AI will try to keep it lower if possible
	RESUPPLY_COOLDOWN_DAYS = 250						# If supplying is interrupted due to insufficient supply, wait for this long before trying to resupply again
}

NFaction = {
	CREATE_OPINION_THRESHOLD = 75						# An opinion below this value will give the chance of create a faction
	CREATE_MIN_SCORE = 15								# Minimum score value to try to create a faction
	JOIN_OPINION_THRESHOLD = 75							# An opinion below this value will give the chance of join a faction
	JOIN_MIN_SCORE = 15									# Minimum score value to try to join a faction
	LEAVE_SCORE_THRESHOLD = 5							# If the join score goes below this value the member will leave the faction
	DEMAND_EXTRA_THRESHOLD = 20							# The AI is going to wait ultil have a sum of power and demand greather than the thersholds + this value to press demands

	DREAD_MODIFIED_BOLDNESS_FACTOR = 1.0				# The effect of Boldness (modified by the liege's Dread) on the AI when considering creating or joining a Faction (Boldness can never make a negative evaluation score positive - it's a bad idea.)

	RATIONALITY_FACTOR = 1.0							# The effect of Rationality on the AI when considering creating or joining a Faction (Rationality can push the evaluation score below or above 0.)

	ENERGY_FACTOR = 1.0									# The effect of Energy on the AI when considering creating or joining a Faction (Energy/Lethargy can only increase or reduce an already positive evaluation score.)
}
