mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 22:06:05 -04:00
AI: Better policy selection
This commit is contained in:
parent
e406533ef0
commit
34fbe9e9a2
@ -72,11 +72,11 @@
|
|||||||
"name": "Liberty",
|
"name": "Liberty",
|
||||||
"era": "Ancient era",
|
"era": "Ancient era",
|
||||||
"priorities": {
|
"priorities": {
|
||||||
"Neutral": 0,
|
"Neutral": 10,
|
||||||
"Cultural": 0,
|
"Cultural": 10,
|
||||||
"Diplomatic": 10,
|
"Diplomatic": 20,
|
||||||
"Domination": 10,
|
"Domination": 20,
|
||||||
"Scientific": 10
|
"Scientific": 20
|
||||||
},
|
},
|
||||||
"uniques": ["[+1 Culture] [in all cities]"],
|
"uniques": ["[+1 Culture] [in all cities]"],
|
||||||
"policies": [
|
"policies": [
|
||||||
|
@ -72,11 +72,11 @@
|
|||||||
"name": "Liberty",
|
"name": "Liberty",
|
||||||
"era": "Ancient era",
|
"era": "Ancient era",
|
||||||
"priorities": {
|
"priorities": {
|
||||||
"Neutral": 0,
|
"Neutral": 10,
|
||||||
"Cultural": 0,
|
"Cultural": 10,
|
||||||
"Diplomatic": 10,
|
"Diplomatic": 20,
|
||||||
"Domination": 10,
|
"Domination": 20,
|
||||||
"Scientific": 0
|
"Scientific": 20
|
||||||
},
|
},
|
||||||
"uniques": ["[+1 Culture] [in all cities]"],
|
"uniques": ["[+1 Culture] [in all cities]"],
|
||||||
"policies": [
|
"policies": [
|
||||||
|
@ -581,13 +581,9 @@ object NextTurnAutomation {
|
|||||||
civInfo.policies.branchCompletionMap.filterKeys { key ->
|
civInfo.policies.branchCompletionMap.filterKeys { key ->
|
||||||
key in candidates
|
key in candidates
|
||||||
}
|
}
|
||||||
// The highest number of adopted child policies within a single candidate
|
|
||||||
val maxCompletion: Int =
|
// Choose the branch with the LEAST REMAINING policies, not the MOST ADOPTED ones
|
||||||
candidateCompletionMap.maxOf { entry -> entry.value }
|
val targetBranch = candidateCompletionMap.minBy { it.key.policies.size - it.value }.key
|
||||||
// The candidate closest to completion, hence the target branch
|
|
||||||
val targetBranch = candidateCompletionMap.filterValues { value ->
|
|
||||||
value == maxCompletion
|
|
||||||
}.keys.random()
|
|
||||||
|
|
||||||
val policyToAdopt: Policy =
|
val policyToAdopt: Policy =
|
||||||
if (civInfo.policies.isAdoptable(targetBranch)) targetBranch
|
if (civInfo.policies.isAdoptable(targetBranch)) targetBranch
|
||||||
|
@ -28,8 +28,6 @@ class PolicyManager : IsPartOfGameInfoSerialization {
|
|||||||
|
|
||||||
var freePolicies = 0
|
var freePolicies = 0
|
||||||
var storedCulture = 0
|
var storedCulture = 0
|
||||||
// TODO: 'adoptedPolicies' seems to be an internal API.
|
|
||||||
// Why is it HashSet<String> instead of HashSet<Policy>?
|
|
||||||
internal val adoptedPolicies = HashSet<String>()
|
internal val adoptedPolicies = HashSet<String>()
|
||||||
var numberOfAdoptedPolicies = 0
|
var numberOfAdoptedPolicies = 0
|
||||||
var shouldOpenPolicyPicker = false
|
var shouldOpenPolicyPicker = false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user