##########################################################################
# Empire Policies
#
# #####
#
# AI:
# Base AI-weight is 100, if unchanged
# AI will grab whatever policy-option has the highest weight
#
# #####
#
##########################################################################


artificial_intelligence_policy = {

	potential = {	
		NOT = { has_ethic = ethic_gestalt_consciousness }
		can_set_ai_policy = yes
	}
	
	option = {
		name = "ai_outlawed"

		valid = {
			NOR = {
				has_ethic = "ethic_materialist"
				has_ethic = "ethic_fanatic_materialist"
				has_ethic = "ethic_xilin_spiritualist_materialist"
			}			
		}
		
		policy_flags = {
			ai_outlawed
		}
		
		AI_weight = {
			modifier = {
				factor = 0
				OR = {
					has_ethic = "ethic_materialist"
					has_ethic = "ethic_fanatic_materialist"
					has_ethic = "ethic_xilin_spiritualist_materialist"
				}
			}
			modifier = {
				factor = 5
				OR = {
					has_ethic = "ethic_spiritualist"
					has_ethic = "ethic_fanatic_spiritualist"
				}
			}
		}
	}
	
	option = {
		name = "ai_servitude"

		valid = {
			NOT = { has_authority = auth_xilin_mind }
		}
		
		policy_flags = {
			ai_servitude
		}
		
		AI_weight = {
			modifier = {
				factor = 5
				has_valid_ai_personality = yes
				has_ai_personality_behaviour = robot_exploiter
			}	
			modifier = {
				factor = 2
				has_valid_ai_personality = yes
				has_ai_personality_behaviour = robot_liberator
			}				
			modifier = {
				factor = 0
				OR = {
					has_ethic = "ethic_spiritualist"
					has_ethic = "ethic_fanatic_spiritualist"
				}
			}
		}
	}
	
	option = {
		name = "ai_full_rights"

		valid = {
			NOR = {
				has_ethic = "ethic_spiritualist"
				has_ethic = "ethic_fanatic_spiritualist"
			}
			NOT = { has_policy_flag = robots_outlawed }
		}
		
		policy_flags = {
			ai_full_rights
		}
		
		modifier = {}
		
		AI_weight = {
			modifier = {
				factor = 5
				has_valid_ai_personality = yes
				has_ai_personality_behaviour = robot_liberator
			}		
			modifier = {
				factor = 0
				OR = {
					has_ethic = "ethic_spiritualist"
					has_ethic = "ethic_fanatic_spiritualist"
				}
			}
		}
	}
}

robot_pop_policy = {

	potential = {	
		NOT = { has_ethic = ethic_gestalt_consciousness }
		can_set_robot_policy = yes
	}
	
	option = {
		name = "robot_pops_outlawed"

		valid = {
			NOR = {
				has_ethic = "ethic_materialist"
				has_ethic = "ethic_fanatic_materialist"
				has_ethic = "ethic_xilin_spiritualist_materialist"
			}				
			NOT = { has_policy_flag = ai_full_rights }
		}
		
		policy_flags = {
			robots_outlawed
		}
		
		AI_weight = {
			modifier = {
				factor = 0
				OR = {
					has_ethic = "ethic_materialist"
					has_ethic = "ethic_fanatic_materialist"
				}
			}
			modifier = {
				factor = 2
				has_valid_ai_personality = yes
				NOR = {
					has_ai_personality_behaviour = robot_exploiter
					has_ai_personality_behaviour = robot_liberator
				}
			}
		}
	}
	
	option = {
		name = "robot_pops_allowed"
		
		policy_flags = {
			robots_allowed
		}
		
		AI_weight = {
			modifier = {
				factor = 5
				has_valid_ai_personality = yes
				has_ai_personality_behaviour = robot_exploiter
			}	
			modifier = {
				factor = 2
				has_valid_ai_personality = yes
				has_ai_personality_behaviour = robot_liberator
			}				
		}
	}
}

pre_sapients = {
	potential = {	
		OR = {
			has_country_flag = found_presapients
			any_planet_within_border = {
				any_pop = {
					is_sapient = no
				}
			}			
		}
	}
	
	option = {
		name = "pre_sapients_protect"
		
		potential = {
			NOR = {
				has_valid_civic = civic_machine_terminator
				has_valid_civic = civic_hive_devouring_swarm
				has_valid_civic = civic_fanatic_purifiers
			}		
		}
		
		policy_flags = {
			pre_sapients_protect
		}
		
		AI_weight = {
			factor = 2
			modifier = {
				factor = 0
				NOT = { has_ai_personality_behaviour = multispecies }
			}
		}
	}	
	
	option = {
		name = "pre_sapients_allow"
		
		potential = {
			NOR = {
				has_valid_civic = civic_machine_terminator
				has_valid_civic = civic_hive_devouring_swarm
				has_valid_civic = civic_fanatic_purifiers
			}		
		}
		
		policy_flags = {
			pre_sapients_allow
		}
		
		AI_weight = {
			factor = 1
		}
	}
	
	option = {
		name = "pre_sapients_eat"
		
		potential = {
			host_has_dlc = "Utopia"
			is_synthetic_empire = no
			NOR = {
				has_valid_civic = civic_hive_devouring_swarm
				has_valid_civic = civic_fanatic_purifiers
			}
		}
		
		valid = {
			NOR = {
				has_ethic = "ethic_xenophile"
				has_ethic = "ethic_fanatic_xenophile"
				has_valid_civic = civic_harmonious
				has_valid_civic = civic_harmonious_tree
				#ϣ鸽ӹʳδ
				AND = {
					exists = overlord
					overlord = { has_authority = auth_xilin_mind }
			  }
			}
		}
		
		policy_flags = {
			pre_sapients_eat
		}
		
		modifier = {}
		
		AI_weight = {
			factor = 10
			modifier = {
				factor = 0
				NOT = { has_authority = auth_hive_mind }
			}
		}
	}	
	
	option = {
		name = "pre_sapients_purge"
		
		valid = {
			NOR = {
				has_ethic = "ethic_xenophile"
				has_ethic = "ethic_fanatic_xenophile"
				has_valid_civic = civic_harmonious
				has_valid_civic = civic_harmonious_tree
				#ϣ鸽ӹδ
				AND = {
					exists = overlord
					overlord = { has_authority = auth_xilin_mind }
			  }
			}
		}
		
		policy_flags = {
			pre_sapients_purge
		}
		
		modifier = {}
		
		AI_weight = {
			factor = 5
			modifier = {
				factor = 0
				is_country_type = default
				NOR = {
					has_ethic = "ethic_xenophobe"
					has_ethic = "ethic_fanatic_xenophobe"
					AND = {
						has_authority = auth_machine_intelligence
						NOR = {
							has_valid_civic = civic_machine_servitor
							has_valid_civic = civic_machine_assimilator
						}
					}
				}
			}
		}
	}
}

core_worlds = {
	potential = {
		has_encountered_other_species = yes
		NAND = { 
		   has_ethic = "ethic_gestalt_consciousness" 
		   NOT = { has_valid_civic = civic_harmonious }
		}
	}
	
	option = {
		name = "core_worlds_all"
		
		policy_flags = {
			core_worlds_all
		}
		
		valid = {
			always = yes
		}
	}
	
	option = {
		name = "core_worlds_citizens_and_slaves"
		
		policy_flags = {
			core_worlds_citizens_and_slaves
		}
		
		valid = {
			allows_slavery = yes
			NOR = {
				has_ethic = ethic_xenophile
				has_ethic = ethic_fanatic_xenophile
				has_valid_civic = civic_harmonious
				has_valid_civic = civic_harmonious_tree
			}
		}

		AI_weight = {
			factor = 10
			modifier = {
				factor = 0
				is_ai = yes
				has_civic = civic_syncretic_evolution
				NOT = { has_ai_personality_behaviour = slaver }
			}				
			modifier = {
				factor = 0
				NOR = {
					has_ethic = "ethic_xenophobe"
					has_ethic = "ethic_fanatic_xenophobe"
					AND = {
						NOT = { has_ai_personality_behaviour = multispecies }
						num_owned_planets > 10
					}
				}
			}
		}		
	}	
	
	option = {
		name = "core_worlds_citizens_only"
		
		policy_flags = {
			core_worlds_citizens_only
		}
		
		valid = {
			NOR = {
				has_ethic = ethic_xenophile
				has_ethic = ethic_fanatic_xenophile
				has_valid_civic = civic_harmonious
				has_valid_civic = civic_harmonious_tree
			}	
		}	
		
		AI_weight = {
			factor = 5
			modifier = {
				factor = 0
				NOR = {
					has_ethic = "ethic_xenophobe"
					has_ethic = "ethic_fanatic_xenophobe"
					AND = {
						NOT = { has_ai_personality_behaviour = multispecies }
						num_owned_planets > 10
					}
				}
			}	
			modifier = {
				factor = 0
				allows_slavery = yes
			}
			modifier = {
				factor = 0
				has_civic = civic_syncretic_evolution
			}			
		}			
	}	
}

refugees = {
	potential = {
		has_encountered_other_species = yes
		is_country_type = default
		OR = {
			NOT = { has_ethic = "ethic_gestalt_consciousness" }
			has_valid_civic = civic_harmonious
			has_valid_civic = civic_machine_servitor
		}	
	}
	
	option = {
		name = "refugees_not_allowed"
		
		valid = {
			NOR = { 
				has_ethic = "ethic_xenophile" 
				has_ethic = "ethic_fanatic_xenophile" 
				has_valid_civic = civic_harmonious
				has_valid_civic = civic_harmonious_tree
				has_authority = auth_xilin_mind
			}
		}
		
		policy_flags = {
			refugees_not_allowed
		}	
	}
	
	option = {
		name = "refugees_only_citizens"
		
		potential = {
			NOT = { has_ethic = "ethic_gestalt_consciousness" }
		}
		
		policy_flags = {
			refugees_only_citizens
		}
		
		valid = {
			NOT = {
				has_authority = auth_hive_mind
				has_authority = auth_xilin_mind
			}
		}
		
		AI_weight = {
			factor = 5
		}
	}
	
	option = {
		name = "refugees_allowed"
		
		policy_flags = {
			refugees_allowed
		}
		
		valid = {
			NOR = { 
				has_ethic = "ethic_xenophobe" 
				has_ethic = "ethic_fanatic_xenophobe" 
			}
		}
		
		AI_weight = {
			factor = 10
			modifier = {
				factor = 0
				NOR = {
					has_ethic = ethic_xenophile
					has_ethic = ethic_fanatic_xenophile
					has_valid_civic = civic_machine_servitor
					AND = {
						has_valid_ai_personality = yes
						NOT = { has_ai_personality_behaviour = multispecies }					
					}
				}
			}
		}
	}
}

slavery = {
	potential = {
		NOT = { has_ethic = "ethic_gestalt_consciousness" }
	}
	
	option = {
		name = "slavery_not_allowed"
		
		policy_flags = {
			slavery_not_allowed
		}
	}
	
	option = {
		name = "slavery_allowed"
		
		valid = {
			NOT = { is_subject_type = signatory }
			OR = {
				has_ethic = ethic_authoritarian
				has_ethic = ethic_fanatic_authoritarian
				has_ethic = ethic_xenophobe
				has_ethic = ethic_fanatic_xenophobe
			}
			#ϣ鸽ӹūƶ
			NAND = {
					exists = overlord
					overlord = { has_authority = auth_xilin_mind }
			}
		}
		
		policy_flags = {
			slavery_allowed
		}
		modifier = {}
		
		AI_weight = {
			factor = 10
			modifier = {
				factor = 0
				has_valid_ai_personality = yes
				NOR = { 
					has_ai_personality_behaviour = slaver 
					has_ai_personality_behaviour = caste_system
				}
			}
			modifier = {
				factor = 0
				has_valid_ai_personality = no
				NOR = {
					has_ethic = ethic_authoritarian
					has_ethic = ethic_fanatic_authoritarian
					has_ethic = ethic_xenophobe
					has_ethic = ethic_fanatic_xenophobe
				}
			}
			# special case for harmonious collectives
			modifier = {
				factor = 0
				has_valid_ai_personality = no
				is_ai = yes
				NOR = {
					has_ethic = "ethic_xenophobe"
					has_ethic = "ethic_fanatic_xenophobe"
					has_ethic = "ethic_militarist"
					has_ethic = "ethic_fanatic_militarist"	
				}
				OR = {
					has_ethic = "ethic_pacifist"
					has_ethic = "ethic_fanatic_pacifist"
					has_ethic = "ethic_xenophile"
					has_ethic = "ethic_fanatic_xenophile"
				}
				OR = {
					has_ethic = "ethic_authoritarian"
					has_ethic = "ethic_fanatic_authoritarian"
				}
				NOR = {
					has_valid_civic = "civic_slaver_guilds"
					has_trait = "trait_decadent"
				}				
			}			
		}
	}
}

purge = {
	potential = {
		NAND = { 
		   has_ethic = "ethic_gestalt_consciousness" 
		   NOT = { has_valid_civic = civic_harmonious }
		}
	}
	
	option = {
		name = "purge_not_allowed"
		
		valid = {
			NAND = { 
				has_ethic = ethic_gestalt_consciousness 
				NOT = { has_valid_civic = civic_harmonious }
			}
			NOT = { has_valid_civic = "civic_fanatic_purifiers" }		
		}
		
		policy_flags = {
			purge_not_allowed
		}
	}
	
	option = {
		name = "purge_displacement_only"
		
		policy_flags = {
			purge_displacement_only
		}

		modifier = {}
		
		valid = {
			NOR = { 
				is_subject_type = signatory
				AND = {
					 has_ethic = ethic_gestalt_consciousness
					 NOT = { has_valid_civic = civic_harmonious }
				}	
				has_ethic = ethic_xenophile
				has_ethic = ethic_fanatic_xenophile
			}
			NOT = { has_valid_civic = "civic_fanatic_purifiers" }
		}
		
		AI_weight = {
			factor = 5
			modifier = {
				factor = 0
				has_valid_ai_personality = yes
				has_ai_personality_behaviour = multispecies
			}
		}
	}	
	
	option = {
		name = "purge_allowed"
		
		policy_flags = {
			purge_allowed
		}
		modifier = {}
		
		valid = {		
			NOT = { is_subject_type = signatory }
			OR = {
				AND = {
			      has_ethic = ethic_gestalt_consciousness
			      NOT = { has_valid_civic = civic_harmonious }
			  }
				has_ethic = ethic_xenophobe
				has_ethic = ethic_fanatic_xenophobe
			}	
			#ϣ鸽ӹ
			NAND = {
					exists = overlord
					overlord = { has_authority = auth_xilin_mind }
			}		
		}
		
		AI_weight = {
			factor = 10
			modifier = {
				factor = 50
				has_ethic = ethic_gestalt_consciousness
			}
			modifier = {
				factor = 0
				OR = {
					has_ethic = ethic_pacifist
					has_ethic = ethic_fanatic_pacifist
				}
			}
			modifier = {
				factor = 0
				has_valid_ai_personality = yes
				NOT = { has_ai_personality_behaviour = purger }
			}
		}
	}
}