title_decisions = {
	
	expd_at_build_hospital_high_prio = {
		ai = no
		is_high_prio = yes
		potential = {
			expd_at_build_hospital_potential = yes
			expd_at_build_hospital_potential_high_prio = yes
		}
		from_potential = {
			expd_at_build_hospital_from_potential = yes
			ai = no
		}
		allow = {
			expd_at_build_hospital_allow = yes
		}
		effect = {
			expd_at_build_hospital_effect = yes
		}
	}
	
	expd_at_build_hospital = {
		only_playable = yes
		ai_check_interval = 12
		potential = {
			expd_at_build_hospital_potential = yes
			OR = {
				expd_at_build_hospital_potential_high_prio = no
				FROM = { ai = yes }
			}
		}
		from_potential = {
			expd_at_build_hospital_from_potential = yes
		}
		allow = {
			expd_at_build_hospital_allow = yes
		}
		effect = {
			expd_at_build_hospital_effect = yes
		}
		ai_will_do = {
			factor = 0.1
			
			# 0% chance with <300 gold; 10% chance with 300; exponentially increasing to 100% with 2000 gold
			modifier = {
				factor = 0
				FROM = { wealth < 300 }
			}
			modifier = {
				factor = 1.5
				FROM = { wealth >= 500 }
			}
			modifier = {
				factor = 2
				FROM = { wealth >= 1000 }
			}
			modifier = {
				factor = 4
				FROM = { wealth >= 2000 }
			}
			
			# Reduce the chance even further if the AI has low wealth and their low learning means the hospital will be a lot more expensive
			modifier = {
				factor = 0.5
				FROM = {
					wealth < 500
					NOR = {
						expd_at_this_characters_learning_skill_is_20_to_30 = yes
						expd_at_this_characters_learning_skill_is_30_to_40 = yes
						expd_at_this_characters_learning_skill_is_40_plus = yes
						expd_at_this_characters_court_physician_has_learning_30_to_40 = yes
						expd_at_this_characters_court_physician_has_learning_40_plus = yes
					}
				}
			}
			modifier = {
				factor = 0.5
				FROM = {
					wealth < 1000
					NOR = {
						expd_at_this_characters_learning_skill_is_30_to_40 = yes
						expd_at_this_characters_learning_skill_is_40_plus = yes
						expd_at_this_characters_court_physician_has_learning_40_plus = yes
					}
				}
			}
			
			# AI will not build a hospital in an outlying province if their capital doesn't have a hospital
			# IE: AI will build a hospital in their capital province before building anywhere else
			modifier = {
				factor = 0
				NOT = { FROM = { is_capital = ROOT } }
				FROM = { capital_scope = { has_hospital = no } }
			}
			
			# AI will not build hospitals in their vassals' provinces until all of their personal provinces have a hospital
			# And, after they have hospitals everywhere in their demesne, AI is rather unlikely to build hospitals in their vassals' provinces
			modifier = {
				factor = 0
				NOT = { holder_scope = { character = FROM } }
				FROM = { any_demesne_province = { has_hospital = no } }
			}
			modifier = {
				factor = 0.02
				NOT = { holder_scope = { character = FROM } }
			}
			
		}
	}
}