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

The AI overbuilds roads #12610

Open
1 task done
metablaster opened this issue Dec 7, 2024 · 2 comments
Open
1 task done

The AI overbuilds roads #12610

metablaster opened this issue Dec 7, 2024 · 2 comments
Labels

Comments

@metablaster
Copy link
Contributor

metablaster commented Dec 7, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Game Version

4.14.3-patch1

Describe the bug

The AI overbuilds roads, almost entire AI territory is covered by roads, this has an impact on AI economy because it's a drain on their gold income reducing their ability to build more units or even worse disbanding their units if they go negative, especially in early game when gold is hard to get.

I see this AI behavior in every game, in early game most AI's are negative gold which hampers their economy.

Steps to Reproduce

  1. Load save file
  2. You play as Rome, one of your scouts is in the territory of India
  3. Locate your scout in India and see how their territory is covered by roads.

Screenshots

This screenshot shows target territory covered by roads:

india

Link to save file

Rim - 821 poteza-roads.zip

Operating System

Linux

Additional Information

The AI should build minimal amount of roads, only as much as needed to connect cities with single road line for income or happiness.
The AI should choose the shortest route to build road between two cities.

AI should also be able to remove surplus roads from conquered territory and rebuild shortest route but that's probably a separate issue.

@metablaster metablaster added the bug label Dec 7, 2024
@gbwiersum
Copy link

gbwiersum commented Dec 25, 2024

I think the problem comes from logic.automation.unit.WorkerAutomation where:
if (tileRankings.bestImprovement != null) { debug("WorkerAutomation: $unit} -> start improving $currentTile") return currentTile.startWorkingOnImprovement(tileRankings.bestImprovement!!, civInfo, unit)

which checks:
data class TileImprovementRank(val tilePriority: Float, var improvementPriority: Float? = null, var bestImprovement: TileImprovement? = null, var repairImprovment: Boolean? = null) private val tileRankings = HashMap<Tile, TileImprovementRank>()

I don't see any logic to check if bestImprovement is returning "road". I'm just getting started on this project (and Kotlin in general...) but it looks like a fairly easy fix.

Ideally, there would be a calculation to determine the marginal cost of one extra move between two points and get a cost/benefit threshold for building a road between two points (how much faster does this make a journey? What's the value of those moves? Weight routes closer to the empires "center of gravity" higher since they get used more...)

hope this helps.

@yairm210
Copy link
Owner

Roads should never be bestImprovement, because for a single tile they have zero utility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants