Settler AI Mod

How many plots should be the distance between cities in Civ5?

  • 3 plots

    Votes: 9 30.0%
  • 4 plots

    Votes: 7 23.3%
  • 5 plots

    Votes: 9 30.0%
  • 6 plots

    Votes: 5 16.7%

  • Total voters
    30

Rozumiyko

Chieftain
Joined
Jan 6, 2013
Messages
24
Location
Portland, Oregon
Settler AI Mod (v 1)
Mod for Civilization V by Matviyko Rozumiyko

Features:
  • AI settlers tend to keep greater distance between founded cities.
  • Improved location choice algorithm is used to found new cities.
  • City borders growth speed is doubled to fill the space between cities.

>> Download <<
 

Attachments

  • Civ5Screen0007.jpg
    Civ5Screen0007.jpg
    326.4 KB · Views: 898
  • Civ5Screen0008.jpg
    Civ5Screen0008.jpg
    310.2 KB · Views: 968
Please download the mod and enjoy playing civ5. Let me know if you notice any bugs or misbehavior while playing the mod. Please feel free to share any ideas about improving the mod. I also added a poll there at the top of the thread - your opinion is important for me.
 
HI Rozumiyko
Thank you for sharing this with us. I will certainly try it out.

I personally think that an intercity spacing of 5 plots is very nice because the AI plays it better (less chokepoints) and we can play on larger maps with standard numbers of cities.

One problem I could not solve and I have tried, is that if I force the minimum distance to 5 plots between cities, sometimes city states will not settle because the placement code for city states ignores the minimum distance.

Do you have any idea how to fix it? I looked in AssignStartingPlots.lua but could not find the solution there. I think that the algorithm is hard-coded for the standard intercity distance but when I change the lines that look like they are hardcoded, it makes no difference.

Thanks again.
 
Thank you for sharing this with us. I will certainly try it out.
You are welcome. You certainly should try this mod. Maybe this is a good solution to your problem. Let me know if it worked for you.

I personally think that an intercity spacing of 5 plots is very nice
In this mod, 5-6 plots is a standard "best" distance between cities when a settler has enough space to choose from. When there is less space, let's say some unsettled area between two or three cities, then the settler may choose a plot there even if it is at distance of about 4 plots from those cities. In some rare cases the settler may choose a location 3 plots from the closest city. This happens when there is a useful piece of area on the coast and if there is no way to settle farther than 3 plots away (because of water).
 
One problem I could not solve
Did you try to write a Lua mod, or you just edited the minimum distance in one of the XML files? How did you try to set the minimum distance? Could you please describe the problem in more details? Do settlers remain at their initial plot without building the city? Otherwise do they ignore the minimum distance which you set and build their cities closer than 5 plots away? Do you have a saved game file which demonstrates the problem?
 
Hi Rozimiyko
Sorry for the slow response, probably I am on the other side of the planet to you :)

Attached is the intercity-5 mod that has everything needed to ensure a minimum spacing of 5 plots (done in XML). Also included is the file assignstartingplots that decides where CS settlers should be placed.

The problem is that the CS settlers are sometimes placed closer than the minimum spacing and then will not settle and remain as zombies until barbarians kill them. This is because there is no settler migration code for CS in the DLL. The problem is that although the settlers are zombies, the CS still behaves as if it were settled! The player still gets CS requests from the unsettled CS.

I have temporarily fixed it (as you can see in the mod), by deleting any unsettled CS at turn 1.

The problem is certainly a challenge! The code in AssignStartingPlots.lua is very complicated!



The problem is that because the AI plays somewhat better on intercity5 (because it can attack cities better), I can decrease the the AI-handicap. However if the AI has less happiness, it starts to make bizarre settlement decisions (without your mod). The AI will see that it needs happiness, and then migrate a settler either escorted or not, across the map looking for a luxury to settle on :crazyeye:

I will try out your mod soon in detail with firetuner, in combination with the intercity5 mod to see if the AI places it's settlers better on a minimum spacing of 5.....

Thanks
Glider
 
Hi Rozimiyko
Tried out your mod with Intercity5 mod and changed only one line of code:
Code:
function EvaluateLocation( originPlot, playerID )
.
.
local city, distanceToCity = getAnyNearestCity( originPlot )
if distanceToCity < [B]***6***[/B] then return 0 end

I increased the AI_handicap to HANDICAP_PRINCE and found that your mod causes the AI to settle much better I think. There are no lua errors in the log either.

Well done! Thanks :goodjob:

NOTE: the AssignStartingPlots.lua file in the Intercity5 mod may have changed a couple of values I can't remember (it's experimental).
 
The problem is that the CS settlers are sometimes placed closer than the minimum spacing and then will not settle and remain as zombies until barbarians kill them.
I see several solutions using Lua. The simplest one is as follows:

"GameEvents.PlayerPreAIUnitUpdate(playerId)" can be used during turn 1 to find settlers among units and reprogram their behavior before the default AI is applied. I think that this event should work fine during turn 1. Anyway there are many other ways to find and select settlers using Lua. I used "unit:GetUnitType() == GameInfo.Units.UNIT_SETTLER.ID" to detect that the unit is a settler. Then you can use "settler:pushMission( MissionTypes.MISSION_FOUND )" to force a settler to found a city immediately at his current plot ignoring any restrictions about distance to other cities. As the result, you can eliminate zombie settlers. I think you can easily do it in your mod. Instead of removing the settlers, just force them to found cities using PushMission.

Another solution is to move a settler to another plot and make it found a city there. This requires implementing a more complicated algorithm similar to the one which I used in my mod.
 
Thankyou Rozumiyko you certainly know your Lua. Had you produced this mod a year or so ago, it would have been exceptionally popular because there were many problems with the AI settling back then. It's not quite so bad since the last patch. I am enjoying this mod a lot so far. Over time it will be interesting to see how much it improves the AI. I also like the expanding culture which is excellent for intercity spacing of 5.

Thanks for those proposed solutions.
Cheers
 
Top Bottom