Settler - in place or search for better?

Joined
Nov 11, 2009
Messages
523
Hey, I have a quick question about this, because it would definitely help a lot with what might be might favourite map script. :D

I've seen that this mod has made settler AI better, but I don't know whether it applies to the first settler, when the players don't normally know much about the land, so I'd like to ask:

If the place where the first settler is spawned has no food resource, for instance, will the AI search for a better spot or will it still settle in place?

And if the spot on which the first settler spawns is 1 off shore, with sea food available, will the AI still settle in place?

I'd love to play SmartMap, it offers anything I could ever ask for, except for this one thing that starting locations aren't always perfect and the AI settles in place regardless. And this situation is most absurd when the AI settles in the middle of the tundra, with food just 1 tile outside of the BFC.

Thanks!
(I'll try this mod anyway, as soon as I figure out how I installed BUG and BULL and how to integrate all three mods :), but I'd like to know what to expect in this particular area)
 

DaveMcW

Deity
Joined
Oct 8, 2002
Messages
6,489
If the place where the first settler is spawned has no food resource, for instance, will the AI search for a better spot or will it still settle in place?

How is the AI supposed to know there are any food resources on the map?

It's up to the map script to provide a balanced start.
 

Fimbulvetr

Emperor
Joined
Nov 5, 2009
Messages
1,250
Location
Austria
The AI knows the whole map, for the purpose of finding places to settle at least. Still it will always settle in place, simply because that's the way it was coded: if we have no city, settle where we stand.

For those 3 mods combined and nothing else, look no further than my signature.
 
Joined
Nov 11, 2009
Messages
523
Well, the AI can at least send its unit(s) to explore in the first turn, and then make a better decision? In at least one of those games, the AI had it within the FoV of the settler that there was a fish resource 3 tiles away from where the settler stood, and still it chose to settle in place.... 1 off coast. :)

Yeah, I guess it's the script's job, but SmartMap is too complex for me to figure out how to better the starting locations balance. :(

Anyway, I've tried this with Better AI and the AI still settles in place. It's annoying if this behaviour is hard-coded. :(

@Fuyu
Yeah, I installed from there. ;) It made the game stop using Blue Marble, but I found a solution in that same thread.
Quite handy! :D
 

Fimbulvetr

Emperor
Joined
Nov 5, 2009
Messages
1,250
Location
Austria
It might be hard-coded right now but that can be changed. You can try removing the first few lines from the CvUnitAI::AI_settleMove() function, maybe the AI settler starts wandering around the map then? Would be interesting at least.
 
Joined
Nov 11, 2009
Messages
523
I've assumed that that method handles all settling, so that if we remove the forced settling in place for 0 cities, it would look for a better city.

I've changed
if (GET_PLAYER(getOwnerINLINE()).getNumCities() == 0)

with
if ((GET_PLAYER(getOwnerINLINE()).getNumCities() == 0) && (GC.getGameINLINE().getElapsedGameTurns() > 3))

as the condition for pushing the mission for settling the city, with the idea that in 3 turns, the AI should have enough time to find a slightly better spot and that we can't allow it to waste too many turns. As a... human :) player, I've never wasted more than 2 turns before settling, and 2 was extreme, so I'm guessing the AI shouldn't need much.

I don't know if/how it will work, but I can't wait to see.
I just don't know something... what should I compile the file into? :)
 

Fimbulvetr

Emperor
Joined
Nov 5, 2009
Messages
1,250
Location
Austria
Unfortunately it's not that simple.
With that change, the AI settler should* move towards a city site and if it reaches it within 3 turns it will settle there. If it is still en route, it will settle where it stands at the beginning of the 4th turn (turn 3) - and it could very well be that it's standing at an even worse place then than it did at the beginning of turn 0.
What should be done is: check if there is a good city site, go there is it can be reached in x turns, and if not just settle in place. That x would be a variable to be set in globaldefines and 0 would be BTS default which would equal always settle in place.
I'm not 100% sure how to do that though, I never touched unit movement/missions at all. Also note that I said should, I think without a city defence unit the settler doesn't even move at all -_-

If you want to compile your own dll, this should help: Modiki: How to Install the SDK

If there's someone who could make it work, that would be jdog btw.
 

phungus420

Deity
Joined
Mar 1, 2003
Messages
6,296
There is a function for plot distance in CvPlot. Simplest way would be to make the AI move it's units first to scout, then check if there is a better plot to found in within 3 tiles; if not settle in place. The actual behavior of such a function will be that the AI settles in place 95% of the time though; an AI can't take into account implied information the same way a human can, or at least coding it to do so is rarely, if ever, worth the effort.
 

Fimbulvetr

Emperor
Joined
Nov 5, 2009
Messages
1,250
Location
Austria
No implied information has to be used as the AI sees the whole map for foundValues. Plot distance is not that great, 3 plots away through dense forest could mean 3 turns lost just as well as it could be reachable in 1 and a half turns. What we'd want is a limit to pathTurns (either 1 or 2, since I'm not sure if 1½ can be coded even), not to plot distance.

edit: and of course Tholal is right.
 

Tholal

Emperor
Joined
May 19, 2009
Messages
1,676
Unfortunately it's not that simple.
With that change, the AI settler should* move towards a city site and if it reaches it within 3 turns it will settle there. If it is still en route, it will settle where it stands at the beginning of the 4th turn (turn 3) - and it could very well be that it's standing at an even worse place then than it did at the beginning of turn 0.

Actually, if you push the found city mission with the move order, then it shouldn't matter how many turns it takes to get there, as the Settler will finish it's current order before looping through this code again.
 
Top Bottom