As a French person I feel like it's my duty to explain strikes to you. - AdrienIer

Create an account  

 
[SPOILERS] Suboptimal Goes Waltzing Matilda

Turn 4

Well, this is unexpected…

[Image: GUFYiYn.jpg]

The warrrior is standing in the middle of the third ring of the city to the south. It looks like there’s also a city close by to the west. Jeez, I hope that’s not an opponent already, though it is within the minimum start distance….either Cornflakes intentionally piled us up to foster conflict early or spaced us out and I’m right on top of two city-states. contemplate

Assuming that the tile directly SE of the mountain is in the third ring of whatever is to the west I think by best settling option is on the forested plains hill adjacent to all of the visible resources. That lets me use the wheat for some added food, preserves both horse tiles as 2Icon_Food/3Icon_Production once the pastures are up and keeps the spot NW of Irukandji available for another close-by city.
Reply

Turn 5

Move the warrior southwest into the tundra forest and…

[Image: GUSpvgX.jpg]

They would like a trade route and I get the first meet envoy giving me the +2 Icon_Production to units in the capital. jive  Their suzerain can build Alcázar improvements which give +2 Icon_Culture when worked and +4 combat strength and two turns of foritification to any unit that occupies it.  It cannot be built next to another Alcázar.  I also realize that I didn’t have the size of the third ring right – I forgot basic geometry.  duh This is the only city in the immediate area.  

And now for some musings

- In test games/maps I’ve seen the Giant’s Causeway more frequently than other natural wonders.  I don’t consider this to be a good thing.

- The fastest route between opposite corners is water-based.

- Harbors can be built in single-tile lakes.

- Standard inland sea maps tend to have a large number of lakes and few rivers.

- Based on SP testing, Australia’s Citadel of Civilization production bonus appears to apply only to intrinsic Icon_Production generation and not to chops/harvests.

- Declaring war on a civ for the purpose of receiving a war declaration from a suzerained city-state to obtain the Defensive Tactics inspiration appears to have been nerfed fixed.  This also means that this tactic is unavailable to activate Citadel of Civilization. [ see https://forums.civfanatics.com/threads/d...ge.624644/ ]
Reply

Turn 6

Happy Thanksgiving to all of the American lurkers out there!

Take a look around the menus, both Emperor K and Alhambram must be working 3 Icon_Food resources as they are now at population 2.

In the land of I Don’t Understand:

[Image: GUZldui.jpg]

It’s going to pick a 3 Icon_Food/1 Icon_Production citrus over a 3 Icon_Food/ 2 Icon_Production spice tile?  rant I’ll have to see if the tile picker stays there, goes to the other citrus or flips over to the spice.

The warrior crosses the river and reveals a lake, some tundra and some plains hills.  Going to move northwest next turn to fully reveal what’s around the mountain then debate on continuing west or heading back to pick up the settler first.
Reply

Does anyone have a clear idea of how the tile picker decides? As far as I can tell, the criteria in order of importance are:
1. In nearest unfilled ring
2. Natural wonder tile (Why? I assume these were good at some point during development and the algorithm never got fixed.)
3. Resource tile
4. Other tile
With any ties randomised.

I'd be interested if anyone can provide a counter-example to this order, or if you can refine it further: does it ever consider tile yields at all? I've also got no idea why it sometimes changes from turn to turn and sometimes sticks rigidly to its guns.
Reply

Turn 7

Looks like the holidays bring some quick turnarounds with them! The scout is finished so I’ve got something else to move around.  I start a slinger for the time being and will switch to a settler next turn.  A quick check of the tile picker shows that it is set on getting the citrus.

Scout moves north out of Irukandji and finds horses and jade to the north.

[Image: GV0wryc.jpg]

The scout will head northwest to the coast to reveal the northern bank of the river, then turn back northeast to head inland and towards the other corner.  In SP games on this map type I’ve gone right by city-states and other civs by staying on the coast.  Not here, though. nono

The warrior moves northwest towards the mountain, revealing a plains hill tile to its SE.  I’ll go west for a couple of more turns and then consider turning back.

Here’s the view with the Appeal lens:

[Image: GV0ww0v.jpg]

I’ve dotmapped out the city that will go here.  With the mountain and the appeal bonus the Campus would be +4 Icon_Science.  A Commercial Hub placed over the wheat tile would be +5 Icon_Gold and I wouldn’t miss the extra Icon_Food from the wheat once the horses are pastured.  Longer term there are some good spots for Outback Stations and a Harbor as a third district could make this city a powerhouse (wait….I’ve said something like that before...haven’t I? mischief)

So, the short-term plan:

- Research Pottery and Writing, stopping the latter halfway until I get the eureka.  All other techs will be researched to one turn from completion until Writing is completed.  At that point I’ll place both Campus districts to lock in the cheap costs and then start winding my way through the tech tree.  Tech priorities after Writing are Bronze Working and Horseback Riding.

- Irukandji will go Settler → Builder unless barbarians show up, at which point I’ll get out a slinger or two and a couple of warriors.  The initial builder here will quarry the stone, farm a rice tile (I’ll purchase one at that point in time) and mine the plains hill tile.  

- The second city will put out a builder first, pasture both horses and then harvest the wheat for some quick population gain.

Having said that I expect to see barbarian horsemen riding out of the fog from the southeast in the next turn or two.  lol
Reply

(November 23rd, 2017, 10:45)rho21 Wrote: Does anyone have a clear idea of how the tile picker decides? As far as I can tell, the criteria in order of importance are:
1. In nearest unfilled ring
2. Natural wonder tile (Why? I assume these were good at some point during development and the algorithm never got fixed.)
3. Resource tile
4. Other tile
With any ties randomised.

I'd be interested if anyone can provide a counter-example to this order, or if you can refine it further: does it ever consider tile yields at all? I've also got no idea why it sometimes changes from turn to turn and sometimes sticks rigidly to its guns.

The only insights that anyone has been able to glean are from the GlobalParameters.xml file which srgtb posted here

Resources and natural wonder are preferred over other tiles and 2nd ring over 3rd ring (based on the distance multiplier and ring cost fields).  All land tiles in a ring should be picked before any water tiles unless there's a resource in the water tile.  Srgtb believes that features (jungle, marsh, forest) are ignored and the terrain does have an "influence cost" associated with it. 

As I type this out it now makes some sense about what's going on with the tile picker, if srgtb is correct.  The spice tile is flat and forested.  The yield of the tile without the resource and forest is only 1Icon_Food/1Icon_Production and the spices bring that up to 3Icon_Food/1Icon_Production.   The picker either considers these to be equal or the spice tile to be worth less than the citrus.  I think that's also why the rice tile isn't being chosen first (it's only 3Icon_Food without the marsh, which is less yield than the others).

As far as picking natural wonder tiles I think this is because the tile picker doesn't (or can't) distinguish between impassable/non-workable and workable tiles.  Some natural wonders (Pantanal, Great Barrier Reef, Ha Long Bay) are passable/workable and you'd most certainly want the tile picker to grab these as soon as it could.

I did notice an instance in PBEM 3 where changing what tile I was working caused the tile picker to change what it was picking.  However, I never got to investigate that further.  There was also a report (unverified) on CivFanatics where someone claimed that putting an escorted builder on a tile with 5 turns or less to go to expansion made the tile picker change its mind and pick that tile.  I did try to glean insights from the Civ V code (the tile expansion code is in the released source code) but the picking method seems quite a bit different.
Reply

More on Cultural Expansion & Gold Costs

After rho21 made the inquiry and I provided a summary answer I took a deeper dive back into the Civ 5 code and some SP Civ 6 save files to see if I could make some headway as to what’s going on.  I think I’ve got some “new” info on this.

Gold Cost to Buy Tiles

It’s been observed that gold cost goes up the more techs and civics are researched.  After looking at some saves and checking various civic & tech counts against purchase costs this formula has turned up yet again:

FLOOR(BaseCost * (1 + Multiplier * FLOOR(100 * MAX(CompletedTechs / 67, CompletedCivics / 50))/100))

For second ring tiles the BaseCost = 50 while for third ring tiles BaseCost = 75.  In both cases the value for Multiplier is 4.

What Tile is Being Picked (and why we all banghead when it makes no sense)

I plowed back through the Civ 5 SDK source code and found the function GetBuyablePlotList in CvCity.  Civ 5 selects the next tile to pick in the following manner:

1) Determines the “influence distance” and multiplies it by iPLOT_INFLUENCE_DISTANCE_MULTIPLIER.  The influence distance is the shortest passable route to a tile from the city.  The function used to find this distance is a pathfinding routine.  This means a third ring tile blocked off by mountains or other impassible terrain has an “influence distance” greater than 3.  It also means that if there’s no path to the tile it will not be picked up by the tile picker.  The value here is referred to as an “influence score”
2) If the distance to the plot is greater than the maximum distance from the city (hardcoded as the 5th ring) the influence score is increased by 100 (iPLOT_INFLUENCE_RING_COST in Civ 5)
3) If the plot is a water plot the influence score is increased by 25 (iPLOT_INFLUENCE_WATER_COST)
4) If the plot has an improvement and the improvement is a barbarian camp the influence score is increased by 100 (same variable as in Step 2)
5) If the plot has an improvement that is not a barbarian camp the influence score is decreased by 5 (iPLOT_INFLUENCE_IMPROVEMENT_COST)
6) Civ 5 checks for roads and adds the road influence cost if roads are present.  Civ 5 has the roads influence cost set at….zero. duh
7) If there’s a resource then 105 is subtracted from the influence cost (iPLOT_INFLUENCE_RESOURCE_COST)
8) If there’s a natural wonder then 105 is subtracted from the influence cost (iPLOT_INFLUENCE_NW_COST)
9) The total available yield from the tile is calculated and subtracted from the influence cost (iPLOT_INFLUENCE_YIELD_COST)
10) If the plot is not adjacent to the city's territory then the influence cost is increased by 1000.
11) The tile picker chooses the lowest score and that’s the next tile.

Look in GlobalParameters.xml and you see all of the above variables (minus the starting "i") with all of the above values. contemplate There are also some extra values, such as the distance multiplier and distance divisor.  However, the Civ 5 routine used these variable names in the routine that determined the Icon_Gold cost of tile purchases.  There’s also terrain values in Terrains.xml as pointed out by srgtb.  

Let’s score out Irukandji and see what that looks like, assuming we use the above process and add in the terrain influence values at the end:

[Image: GV4KWTX.jpg]

Hmmm….the spices score less than the citrus so should be the first tile picked.  What’s going on?  

Civ 5 used a pathfinding routine to determine the distance, not absolute tile distance.  What if the “influence distance” is “movement distance”?  Using the distance as Movement Points expended to reach the tile, counting river crossings as zero, Irukandji rescores as

[Image: GV4L4pu.jpg]

This puts the citrus first in the tile picker but also moves the wheat ahead of the spices. contemplate

I checked some of my other saves and noticed one case where a 2 Icon_Food grassland was being picked over a 2 Icon_Food/1 Icon_Production grassland hill tile.  This also applies in the case of srgtb’s observation of a plains hill tile being picked over a plains forest tile.  In both cases the “better” tile took more movement points to enter.

What about 3rd ring vs. 2nd ring?  The easy answer is to add the PLOT_INFLUENCE_RING_COST value multiplied by the ring position to each score .  Thus all 3rd ring scores will be 100 higher than a similar 2nd ring tile score.  

Now, how to test this out?  Well, I’ll score out each city’s 2nd ring when it’s founded and post an image showing the scores. As the game progresses we can see if the scores properly anticipate the tile picker.  Note that buying tiles shouldn’t matter in most cases as the picker will move to the next lowest score.  In the case of Irukandji we won’t find out if I’ve scored the spices correctly because I’ll be buying that tile before the city acquires both citrus and the wheat.
Reply

Awesome, this is going to be a really educational thread. smile
Reply

Brilliant work doing the math there, suboptimal. I really hope you've cracked the code, it'd be nice for the tile-picker mystery to finally be resolved.

What could cause the picker to alternate between options as it sometimes does? What variables in the equation could change from turn to turn?
I Think I'm Gwangju Like It Here

A blog about my adventures in Korea, and whatever else I feel like writing about.
Reply

I don't know. I'll need to take a look back at the code later today because I vaguely remember seeing a comment in there about picking tiles closer to resources. If that is the case then the current citrus tile makes further sense (and is why it's not flip-flopping). Anecdotally I haven't seen flip-flopping in a SP game, only in MP. If that turns out to be the case it is probably the fact that the game engine recomputes the scores on reload and if there's a tie it depends on the sorting (or in a dead tie there's code to flip a coin). I don't see any other variables that change from turn to turn so the "sort on load" might be a culprit.
Reply



Forum Jump: