1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Post a (tough) Deity map for me to play

Discussion in 'Civ4 - Strategy & Tips' started by Lain, Jul 19, 2017.

  1. Kid R

    Kid R Emperor

    Joined:
    Jan 26, 2009
    Messages:
    1,487
    Re. barb cities, maybe it could be checked by waiting till a barb city founds, then reloading to the turn before and looking what units are on the tile. In the code, the IBT sequence spawns barb cities immediately before it spawns barb units, so it couldn't create a unit, then have that unit create a city, on the same turn.

    Here's a rough reading of the code. Couldn't see anything about existing barb units on the tile. The only thing that seems to look at units was the spawnbusting test. It is complicated though so definitely possible to miss something. Also there might be something in the Python which rejects cities unless there's a barb unit there.
    Spoiler :

    Each turn (CvGame::doTurn())
    • Do all sorts of game admin
    • Including barb city spawning (CvGame::createBarbarianCities()), which goes something like:
    Do nothing if
    • "getMaxCityElimination" game option is >0 (not sure what that is)
    • No barbs game option
    • Some Python function "createBarbarianCities" ==1 (don't know what that is)
    • The game has entered an era with no barb city creation
    • The game difficulty has barb city density set to 0
    • Average # cities for non barb players left in the game is < 2
    • A RNG-based and game-speed-based test on how long since the last barb city was created
    • A RNG-based test against difficulty setting for barb city creation probability
    Some high level tests on potential tiles:
    • Not water
    • Not currently visible to any non-barb team
    • Barb cities on the landmass should not already be above a difficulty-defined threshold of barb cities per unowned tile
    • (If the barbs have a whole landmass to themselves it seems to loosen that test so it can pack even more in. Not sure about that.)
    Then for each tile that passes those tests, it assesses the suitability in more detail using a function (CvPlayerAI::AI_foundValue) which is also called by normal AI city founding.
    First a couple of red lines
    • Can a city even be founded here (peaks, water, closeness to other cities etc).
    • Is there a unit of any other team inside a square around the plot of size MIN_BARBARIAN_CITY_STARTING_DISTANCE (XML parameter: 2). If there is, then no barb city (spawnbusted!)
    • Would the BFC contain less than 14 usable tiles not owned by other civs. If not, then no barb city.
    Fine-tune suitability based on
    • Number of "bad tiles", and "good tiles" on currently unowned tiles.
      • Resources etc. It *does* take account of whether the AI/barbs have the reveal tech.
    • Looks like it outright rejects sites with no unowned BFC bonuses to claim
    • Tile yields
      • Terrain features like freshwater, coast, hills (very strongly desirable!)
      • Distance other cities (barb: quite undesirable to be near, other player: very undesirable to be near)
      • It somehow takes into account where tiles are shared with other cities of the same team. Don't quite follow that bit.
    Then it founds a city on the best available site it looked at, if there were any that weren't rejected.
     
    Excal and Jarno like this.
  2. drewisfat

    drewisfat Prince

    Joined:
    Feb 8, 2011
    Messages:
    446
    Not a code diver, but I'm pretty confident in the conventional wisdom here..... barb cities require a barb unit to be present and don't follow the normal spawn/fog busting rules that barb units do. Meaning a city can spawn in a tile that's 2 tiles away from a unit if it's not visible, and if a barb is present. That syncs up with my anecdotal experience, of sometimes a barb city spawning even in an area that's spawn busted, and also from crying out at "bad luck" that a barb city spawned the turn i moved my unit away. In reality I'm overstating how unlucky I am, since I probably moved my unit away because it was chased by a strong barb, and then that matches conditions for barb city creation for possibly the first time. It also matches with my experience like Fippy said, that in isolation games, where I often have much of the island unsettled for 100+ turns, there's no breaches with barb cities once I've spawn busted all possible barb units, even though I'm certainly not maintaining vision on all tiles. It even syncs up with the hellish Charlie game. The reason it's so very likely that a barb city spawns above your capital, is because a barb unit will spawn there very quickly. It's connected by land to the continent with an impassable mountain, so that unit can't ever leave. Since that unit is stuck there, a barb city is inevitable in fairly short order.
     
  3. Kid R

    Kid R Emperor

    Joined:
    Jan 26, 2009
    Messages:
    1,487
    Yeah I guess no reason barb cities can't spawn where a barbarian is. Especially in the case of human areas if the player is deliberately fogbusting large numbers of tiles without settling them. The barb city spawn code is attracted by the number of unowned tiles - AI areas will have more AI cities, so fewer unowned tiles.

    Edit:
    Spoiler :

    Check this out! A reliable way to prevent barb cities, other than ofc spawnbusting everywhere, could be to pay attention to the number of unowned tiles on the landmass. If we can settle a city, or force a border pop, to bring it below 80, no barb cities should spawn at all. If <160 unowned tiles and there's already 1 barb city, no more should spawn. Etc. I guess at the risk of overthinking it you could even leave an undesirable area fogged to tempt the barbs to settle it, using up their quota of cities on your continent.

    Edit2. 80 is quite a lot of tiles - I mean in iso you might only have that amount of tiles for your whole island, and this would suggest you're immune to barb cities then. I feel sure I can remember getting barb cities in small unused areas in iso - plus I usually play immortal where the threshold is 90 tiles, not 80. Will have to keep an eye on this in future games - memory can be a funny thing can't it! Just one quick try-out now: clicked through 200 turns in iso on a ~80 tile island with just one city and no fogbusters. 0 barb cities for me. Shaka got an early one on his bigger island before he'd filled it out much, and the main continent ended up getting 3. Open verdict :crazyeye:
    Code:
        for (iI = 0; iI < GC.getMapINLINE().numPlotsINLINE(); iI++)
        {
            pLoopPlot = GC.getMapINLINE().plotByIndexINLINE(iI);
    
            if (!(pLoopPlot->isWater()))
            {
                //Only spawn city on non-visible tiles
                if (!(pLoopPlot->isVisibleToCivTeam()))
                {
                    //I think this means landmass - e.g. say 79 tiles
                    iTargetCities = pLoopPlot->area()->getNumUnownedTiles();
    
                    //Barb-only continents?
                    if (pLoopPlot->area()->getNumCities() == pLoopPlot->area()->getCitiesPerPlayer(BARBARIAN_PLAYER))
                    {
                        //Increase desired density of barb cities
                        iTargetCities *= 3;
                    }
    
                    //On deity this is 80 (settler 160). So if 79 unowned tiles, target is 0
                    iTargetCities /= GC.getHandicapInfo(getHandicapType()).getUnownedTilesPerBarbarianCity();
    
                    //Only proceed if existing count of barb cities in area (landmass?) is not at the target
                    if (pLoopPlot->area()->getCitiesPerPlayer(BARBARIAN_PLAYER) < iTargetCities)
                    {
                        iValue = GET_PLAYER(BARBARIAN_PLAYER).AI_foundValue(pLoopPlot->getX_INLINE(), pLoopPlot->getY_INLINE(), GC.getDefineINT("MIN_BARBARIAN_CITY_STARTING_DISTANCE"));
    
                        iValue += (100 + getSorenRandNum(50, "Barb City Found"));
                        iValue /= 100;
    
                        if (iValue > iBestValue)
                        {
                            iBestValue = iValue;
                            pBestPlot = pLoopPlot;
                        }
                    }
                }
            }
        }
    A couple of other interesting things from watching spawns in worldbuilder just now on some deity fractal maps. One is the non-barb cities on continent thing can't be true, because we often see barb cities on their own continent. Another surprising thing was barb units do not appear to spawn bust each other - I guess that explains why we are sometimes attacked by groups from the same direction.
     
    Last edited: May 14, 2020
  4. Tobiyogi

    Tobiyogi King

    Joined:
    Nov 23, 2018
    Messages:
    734
    Gender:
    Male
    Location:
    Berlin, GE
    Hello @Lain I would love to see you try again AW someday on the Live-Stream. I don't know if it is possible at all to win there on Deity (you might have done it offline).... Immortal would be perfectly fine, maybe some extra challenges like a peaceful leader, pangea map, raging barbs, whatever you think would make it more difficult, because you have already beaten IMMAw with tech trading on...
     
  5. Fippy

    Fippy Micro Junkie Queen

    Joined:
    Mar 17, 2013
    Messages:
    11,078
    Gender:
    Female
    It's possible but not with an aggressive (Qs) approach if facing several AIs,
    need something like Mansa's Skirmishers.
    Another option would be Praets, but needs unrestricted leaders.
     
  6. Tobiyogi

    Tobiyogi King

    Joined:
    Nov 23, 2018
    Messages:
    734
    Gender:
    Male
    Location:
    Berlin, GE
    Yeah, I got my best AW results with strong unrestricted combos, so maybe for a Livestream either a strong combo for Deity, or a very weak one on immortal :lol:
    Maybe it's just an illusion, sometimes i got the impression that unrestricted confuses the AI in its usual patterns, like some peacemonger not knowing what to do with Keshiks etc...
     
  7. sylvanllewelyn

    sylvanllewelyn Perma-newb

    Joined:
    Oct 19, 2006
    Messages:
    1,292
    "Always War" is boring. I think "random personalities", "aggressive AI", and "unrestricted leaders" at Immortal is more entertaining to watch. The viewers are kept in suspense.
     
  8. Sleeping Dragon

    Sleeping Dragon Chieftain

    Joined:
    Mar 8, 2009
    Messages:
    36
    A truly terrible capital I generated today with Julius Caesar. Hope the file works as I have an old version of BUG mod.



    Spoiler :
    Other than the rubbish plains cow start this seems pretty playable, settling 1N gets double plains cow + iron + copper for a production bonanza but it's not like you'd have any reason to do that on turn 1.
     

    Attached Files:

  9. Sleeping Dragon

    Sleeping Dragon Chieftain

    Joined:
    Mar 8, 2009
    Messages:
    36
    And a somewhat odd isolation map with Cyrus.



    Spoiler :
    I swear I didn't world builder this. If you step one square to the southeast...


     

    Attached Files:

Share This Page