Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI citizen focus change #11908

Merged
merged 71 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
7ed4c0d
AI behaviour changes
EmperorPinguin Jun 23, 2024
47184b0
Merge branch 'master' of https://github.com/EmperorPinguin/Unciv
EmperorPinguin Jun 23, 2024
e856a76
Merge branch 'master' of https://github.com/EmperorPinguin/Unciv
EmperorPinguin Jun 23, 2024
b571e76
Update Automation.kt
EmperorPinguin Jun 23, 2024
cee0287
Update Automation.kt
EmperorPinguin Jun 23, 2024
16ae6d9
Update Automation.kt
EmperorPinguin Jun 23, 2024
a769a52
Update Automation.kt
EmperorPinguin Jun 23, 2024
9c8f2e2
Update Automation.kt
EmperorPinguin Jun 23, 2024
777b828
Update ConstructionAutomation.kt
EmperorPinguin Jun 23, 2024
2a4f9b0
Update Automation.kt
EmperorPinguin Jun 23, 2024
33b9fc7
Reverting some changes
EmperorPinguin Jun 23, 2024
e311e17
Changes
EmperorPinguin Jun 24, 2024
cade007
revert changes
EmperorPinguin Jun 24, 2024
318c396
revert changes
EmperorPinguin Jun 24, 2024
012afb5
revert changes
EmperorPinguin Jun 24, 2024
f4d02c8
revert changes
EmperorPinguin Jun 24, 2024
cae12b6
Update CityLocationTileRanker.kt
EmperorPinguin Jun 24, 2024
9040bab
Citizen assignment for stat conversion
EmperorPinguin Jun 24, 2024
a33d7f4
Merge branch 'yairm210:master' into master
EmperorPinguin Jun 25, 2024
e53f887
Merge branch 'yairm210:master' into master
EmperorPinguin Jun 25, 2024
3f540a8
Update CityLocationTileRanker.kt
EmperorPinguin Jun 25, 2024
0e5db36
Merge branch 'yairm210:master' into master
EmperorPinguin Jun 26, 2024
43cf8a3
Merge branch 'yairm210:master' into master
EmperorPinguin Jun 26, 2024
85743fb
Merge branch 'yairm210:master' into master
EmperorPinguin Jun 27, 2024
a1f5905
Reduce AI settling
EmperorPinguin Jun 27, 2024
d061b67
Merge branch 'yairm210:master' into master
EmperorPinguin Jun 27, 2024
4257a0f
Avoid AI building units when in negative Supply
EmperorPinguin Jun 27, 2024
44c8a90
Merge branch 'yairm210:master' into master
EmperorPinguin Jun 27, 2024
5f42454
Update CityLocationTileRanker.kt
EmperorPinguin Jun 27, 2024
6b49cdc
Merge branch 'master' of https://github.com/EmperorPinguin/Unciv
EmperorPinguin Jun 27, 2024
383a083
Update CityLocationTileRanker.kt
EmperorPinguin Jun 27, 2024
31e3c44
Update CityLocationTileRanker.kt
EmperorPinguin Jun 27, 2024
cd7c911
Merge branch 'yairm210:master' into master
EmperorPinguin Jun 28, 2024
958b646
Update ConstructionAutomation.kt
EmperorPinguin Jun 28, 2024
5f91c79
Merge branch 'yairm210:master' into master
EmperorPinguin Jun 28, 2024
809b0fc
Update build.gradle.kts
EmperorPinguin Jun 28, 2024
f2573d8
Update gradle-wrapper.properties
EmperorPinguin Jun 28, 2024
9bef165
Update CityLocationTileRanker.kt
EmperorPinguin Jun 28, 2024
3239649
Update CityLocationTileRanker.kt
EmperorPinguin Jun 28, 2024
6f7c7c8
Merge branch 'yairm210:master' into master
EmperorPinguin Jun 28, 2024
301ab4e
Update ConstructionAutomation.kt
EmperorPinguin Jun 28, 2024
f8f364e
Merge branch 'master' of https://github.com/EmperorPinguin/Unciv
EmperorPinguin Jun 28, 2024
df80b10
Update CityLocationTileRanker.kt
EmperorPinguin Jun 28, 2024
ef4f189
Merge branch 'master' of https://github.com/EmperorPinguin/Unciv
EmperorPinguin Jun 30, 2024
0fda42b
Merge branch 'yairm210:master' into master
EmperorPinguin Jun 30, 2024
55e1f7c
Merge branch 'yairm210:master' into master
EmperorPinguin Jul 2, 2024
bc6172b
Merge branch 'yairm210:master' into master
EmperorPinguin Jul 2, 2024
213c896
AI changes for humans
EmperorPinguin Jul 2, 2024
5f4e093
Fix puppet focus
EmperorPinguin Jul 3, 2024
61d8299
Merge branch 'yairm210:master' into master
EmperorPinguin Jul 4, 2024
7ff9018
Merge branch 'yairm210:master' into master
EmperorPinguin Jul 6, 2024
428193b
Merge branch 'yairm210:master' into master
EmperorPinguin Jul 15, 2024
001269a
Update Automation.kt
EmperorPinguin Jul 17, 2024
344dd81
Puppet focus
EmperorPinguin Jul 17, 2024
bf0a8e7
Update Automation.kt
EmperorPinguin Jul 17, 2024
545f8c2
Update Automation.kt
EmperorPinguin Jul 17, 2024
395ac8f
Update Automation.kt
EmperorPinguin Jul 18, 2024
96acd16
Update Automation.kt
EmperorPinguin Jul 18, 2024
9e73243
Update Automation.kt
EmperorPinguin Jul 18, 2024
5de758d
Merge branch 'yairm210:master' into master
EmperorPinguin Jul 18, 2024
6fc1b0c
Update Automation.kt
EmperorPinguin Jul 18, 2024
53057d9
Merge branch 'master' of https://github.com/EmperorPinguin/Unciv
EmperorPinguin Jul 18, 2024
d5e270b
Update Automation.kt
EmperorPinguin Jul 19, 2024
c34b62b
Update Automation.kt
EmperorPinguin Jul 19, 2024
611378b
Update Automation.kt
EmperorPinguin Jul 19, 2024
1e4d88b
Update Stats.kt
EmperorPinguin Jul 23, 2024
5863788
Merge branch 'yairm210:master' into master
EmperorPinguin Jul 24, 2024
c896436
Update CityTurnManager.kt
EmperorPinguin Jul 24, 2024
8bb6b37
Remove specialist science modifier
EmperorPinguin Jul 25, 2024
0d3d37b
Merge branch 'yairm210:master' into master
EmperorPinguin Jul 25, 2024
a73bf52
Merge branch 'master' of https://github.com/EmperorPinguin/Unciv
EmperorPinguin Jul 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions core/src/com/unciv/logic/automation/Automation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,30 @@ object Automation {
else
yieldStats.food /= 2
} else if (!city.avoidGrowth) {
// NoFocus or Food/Growth Focus. Target +2 Food Surplus
if (surplusFood < 2)
yieldStats.food *= 8
else if (city.population.population < 5)
yieldStats.food *= 3
// NoFocus or Food/Growth Focus. Target +10 Food Surplus when happy
if (surplusFood < 0)
yieldStats.food *= 8 // Starving, need Food, get to 0
else if (surplusFood < 10 && city.civ.getHappiness() > -1)
yieldStats.food *= 2
else if (city.civ.getHappiness() < 0) {
// 75% of excess food is wasted when in negative happiness
yieldStats.food /= 4
}
}

if (city.population.population < 5) {
if (city.population.population < 10) {
// "small city" - we care more about food and less about global problems like gold science and culture
// Food already handled above. Science/Culture have low weights in Stats already
yieldStats.gold /= 2 // it's barely worth anything at this point
} else {
if (city.civ.gold < 0 && city.civ.stats.statsForNextTurn.gold <= 0)
yieldStats.gold *= 2 // We have a global problem

if (city.tiles.size < 12)
yieldStats.culture *= 2
// Food already handled above. Gold/Culture have low weights in Stats already
yieldStats.science /= 2
}

if (city.civ.getHappiness() < 0)
yieldStats.happiness *= 2
}
if (city.civ.stats.statsForNextTurn.gold < 0) {
// We have a global problem, we need to deal with it before it leads to science loss
yieldStats.gold *= 2
}

if (city.civ.getHappiness() < 0) {
// 75% of excess food is wasted when in negative happiness
yieldStats.food /= 4
yieldStats.happiness *= 2
}

if (allTechsAreResearched) {
Expand All @@ -115,7 +114,7 @@ object Automation {
}

if (city.cityConstructions.getCurrentConstruction() is PerpetualConstruction) {
// With 4:1 conversion of production to gold, production is overvalued by a factor (12*4)/8 = 6
// With 4:1 conversion of production to science, production is overvalued by a factor (12*4)/7 = 6.9
yieldStats.production /= 6
}

Expand Down
8 changes: 4 additions & 4 deletions core/src/com/unciv/models/stats/Stats.kt
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ open class Stats(
fun applyRankingWeights() {
food *= 14
production *= 12
gold *= 8 // 3 gold worth about 2 production
science *= 7
culture *= 6
gold *= 6 // 2 gold worth about 1 production
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AI generally has a problem with obtaining gold. This is partly because there aren't many gold opportunities early on. But reducing the value of gold wouldn't help.

Copy link
Contributor Author

@EmperorPinguin EmperorPinguin Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not just the AI who uses AI citizen assignment, but also many humans do it. In the early game, the most efficient use of gold is via unit upgrades, which is a gold:production conversion of 2:1. Late in the game, with stock exchanges built, the conversion of base gold to base production is more like 2*(1+0.1+0.1+0.15+0.2) : 1*(1+0.25+0.25+0.25) = 1.77:1, or even 1.19:1 with Professional Army/Pentagon. It makes sense to scale the value of gold with era, but if I'm not mistaken the AI already takes modifiers from buildings into account.

Copy link
Contributor Author

@EmperorPinguin EmperorPinguin Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason AI loses as much gold as it does, got more to do with how it picks city constructions, and by building roads without connecting cities. Improving their worker management might help quite a bit, but I'm not sure how to do so.

science *= 9
culture *= 8
happiness *= 10 // base
faith *= 5
faith *= 7
}

/** ***Not*** only a debug helper. It returns a string representing the content, already _translated_.
Expand Down
Loading