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