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 worker build roads improvement #11615

Merged
merged 8 commits into from
May 21, 2024
Merged

Conversation

tuvus
Copy link
Collaborator

@tuvus tuvus commented May 17, 2024

This PR is brought to you by A* and #10631, thanks willjallen!

If you haven't noticed, workers will only try to connect cities to the capital and not because of movement reasons because of #10918 and #10776. This PR aims to fix that and have workers create a road network.

Here are some notes on the changes:

  • We build roads between neighboring cities using the new City.neighboringCities variable. This variable will probably be very important in the future.
  • Which road is the "from" road and the "to" road depends on their order in the civ.cities list. This is important for ensuring multi turn consistency of the planned roads.
  • Road building priority depends on the state of the road and if the city is connected to the capital or not.
  • If there are no roads to build to nearby cities and the city isn't connected to the capital yet, then we will try to build a road to the closest connected city. (I have not changed this very much)
  • The A* algorithm tries to reuse railroads and roads, however it turns out that railroads and roads should have the same priority. If they don't the AI might try to build railroads off of roads or not upgrade the roads.
  • Sometimes there is a lazy missionary blocking a road, now the workers will swap with it to get to the tile they want.
  • I made some small changes that should support military workers better, but I haven't tested it yet and should probably leave them for a different PR.
Picture of the new road network

WorkerRoadAIImprovement

@yairm210
Copy link
Owner

I haven't got the brain to work through everything you did here, in general I trust you that it's better than the current version so I'll approve on those grounds
Worst case we'll get bug reports

@SomeTroglodyte
Copy link
Collaborator

Worst case we'll get bug reports

🤣 🤪 No, we'll get them assuredly. Worst case is - tuvus elopes and leaves us stumped.
My brain would go up in flames too 🧠 🔥 trying to understand all that automation stuff...

trust

exactly

@yairm210 yairm210 merged commit 783c0aa into yairm210:master May 21, 2024
3 checks passed
@tuvus tuvus deleted the AIWorkerRoads branch June 1, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants