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

When do barbarian units enter cultural borders

Discussion in 'Civ4 Strategy Articles' started by regoarrarr, Nov 17, 2008.

  1. DanF5771

    DanF5771 Chieftain

    Joined:
    Feb 21, 2008
    Messages:
    1,194
    Barb Galleys use UNITAI_ATTACK_SEA and thus require their own AI function CvUnitAI::AI_barbAttackSeaMove(). Obviously, you won't find any AI_attackCity or AI_targetCity calls in there, as boats are only allowed to attack units outside cities. Also, there aren't any similar NumCities-thresholds implemented here and the AreaAI of their area (= water!) has no effect. So once they are around, they will check their valid options in the following order:
    1. flip a coin (50% chance) and -if lucky- check whether an improvement can be pillaged this turn (AI_pillageRange(iRange=1))
      --> they will move onto Fishing Boats in adjacent tiles and pillage them
      .
    2. check whether an enemy unit can be attacked on this or on the next turn (AI_anyAttack(iRange=2, iOddsThreshold=25))
      --> they will target your Work Boats 4 tiles away; this can be exploited to keep them away from your improvements by some nice disco-fox dancing ;) or to lure them into the fishing grounds of your neighbors
      .
    3. check whether an improvement can be pillaged within 4 turns ((AI_pillageRange(iRange=4))
      --> they will use their advanced AI radar to spot your improvements 7 tiles away :eek:, however, this radar can only detect improvements in the fog, if they exist for more than 20 turns (improved knowledge!, 5 turns for land units and improvements on land); the closest improvement "wins" (max(pillageValue/pathTurns))
      .
    4. AI_heal()
      .
    5. AI_patrol()
      --> move into a random adjacent tile (iValue = 1...10,000); prefer unowned tiles (+20,000) and tiles not adjacent to borders (+10,000); if movement points left, recalculate ALL options (if the patrol-move reveals a "fresh" improvement, that was hidden from the AI radar in the fog before, option 3 will now be enabled and the respective mission (AI_pillageRange(iRange=4)) will be pushed)

    At what time will the game spawn barb Galleys?
    • the era of barb animals must be over (NumCities >= 3/2*NumPlayers; GameTurns > Handicap.BarbarianCreationTurnsElapsed * GameSpeed.BarbPercent)
    • the barbs must know Sailing

    How do barbs acquire their techs?
    • Their real research rate is almost guaranteed to be 0, since they aren't allowed to have a Palace (8 commerce) and thus suffer from high maintenance (but they don't lose units via STRIKE).
    • So they merely receive the 1 free beaker everybody gets (BASE_RESEARCH_RATE) for their current research plus 3% (BARBARIAN_FREE_TECH_PERCENT) of the cost of a tech scaled by the percentage of players who know it for each technology each turn. Hence, if the majority of the players in the game knows Sailing, it won't be long until the first barb Galleys come visit your fishing grounds.
     
  2. Kaleb

    Kaleb Chieftain

    Joined:
    Jan 14, 2004
    Messages:
    2,449
    Location:
    London
    How does barb visibility work, I'm not entirely sure how that is calculated. Do they just see everything?
     
  3. DanF5771

    DanF5771 Chieftain

    Joined:
    Feb 21, 2008
    Messages:
    1,194
    They generally see all units and cities within the current search radius for a specific mission -- this radius is a function of their base movements and the passed iRange argument. Improvements are a bit special, they need to be revealed already or be old enough (see above), otherwise they get a pillage value of 0 and thus won't be pillaged. The barbs always know exactly where their target city is located (mostly your capital or coastal city with a wonder).
     
  4. oyzar

    oyzar Have quit civ/forums

    Joined:
    Oct 7, 2006
    Messages:
    6,923
    Location:
    Norway
    When does barb annimals stop to spawn and how?
     
  5. DanF5771

    DanF5771 Chieftain

    Joined:
    Feb 21, 2008
    Messages:
    1,194
    Barb Animals start appearing after game turn 5 (hard coded, independent of game speed). As mentioned earlier the game stops spawning them if both of the following two conditions are met:
    1. The average number of (non-barb) cities per player must be >= 1.5.
      .
    2. A certain number of game turns must have elapsed (depending on difficulty [iBarbarianCreationTurnsElapsed] and game speed [iBarbPercent], marathon is special with 400%).

    So in a quick deity game animals are usually only created in just 1 IBT (5->6).

    When the era of barb animals is over, the existing creatures are not eradicated in 1 major extinction event. Instead, the game kills off 1 animal per turn until they are all gone and will insert regular barb units (Warriors, Archers, ...) as they are "needed" during the next IBT (can be > 1 unit/turn!, ALL required units are created immediately).
     
  6. Yamps

    Yamps Chieftain

    Joined:
    Aug 30, 2007
    Messages:
    2,728
    Location:
    Zagreb, Croatia
    Great info Dan as usual. :) Just a quick question, do roads also count as improvements when it comes down to border improvement pillaging?

    I have an idle worker waiting for BW with barbs roaming around. Should I build a road on a border tile? :crazyeye:
     
  7. Whiskey_Lord

    Whiskey_Lord Chieftain

    Joined:
    Jul 15, 2008
    Messages:
    2,163
    Really? For me it's been the opposite. The game I'm playing now has seen barb axemen attack fortified longbowmen on hills and cities, ignoring improvements. I even had barb warriors attacking my scouting dog soldier in a previous game. In my experience, barbs are pretty darn suicidal.
     
  8. DanF5771

    DanF5771 Chieftain

    Joined:
    Feb 21, 2008
    Messages:
    1,194
    Yes, they do. Although (as you hinted at) roads/railroads aren't Improvements technically but Routes instead, they do have an AI_pillageValue > 0 which is required to trigger the AI_pillageRange mission.

    If only their suicidal tendencies were a bit more stable... I have described the barbs' fluctuating attack courage in post#12 of this thread.

    ~~~~~~~~~~~~


    A quick tip on fogbusting:

    I'm not sure how many of you fellow civfanatics know about the GlobalDefines value MIN_BARBARIAN_STARTING_DISTANCE = 2 and already exploit it. It means that new barbarian units are not allowed to spawn within a 2 tile radius of ANY existing unit (including other barb units) on the map. This rule allows very efficient "fogbusting" on smaller landmasses. Here is an example (spoiler for current LHC Huayna Capac checkpoint 1):
    Spoiler :

    2 Quechuas and 1 Scout are all I need to keep my lands barb-free :D. It is not required to have active vision for all the tiles (the fog doesn't matter). I've changed the Dotmap-function of BUG to display the no-spawn areas for my three units.

    Note that barb cities CAN appear 2 tiles away from my units if the tile is in the fog though.
     
  9. oyzar

    oyzar Have quit civ/forums

    Joined:
    Oct 7, 2006
    Messages:
    6,923
    Location:
    Norway
    So why was this thread never made into an article?
     
  10. huerfanista

    huerfanista Chieftain

    Joined:
    Dec 25, 2006
    Messages:
    1,276
    Whoah! :eek::eek::eek: That was certainly worth the price of admission! :lol: Thanks, Dan. :goodjob:
     
  11. Gliese 581

    Gliese 581 Your average civ junkie

    Joined:
    Oct 11, 2007
    Messages:
    2,503
    Location:
    Sweden
    That's certainly a great revelation when it comes to fogbusting, I had no idea this was the case. That should help alot. :)
     
  12. FlyinJohnnyL

    FlyinJohnnyL You need more workers....

    Joined:
    Feb 17, 2007
    Messages:
    686
    Location:
    Jacksonville, FL
    So basically the range around a unit is just a BFC but with the corners as well? And this may be a dumb question since we already have a way to exploit them but...does this count for barb galleys as well?
     
  13. Gliese 581

    Gliese 581 Your average civ junkie

    Joined:
    Oct 11, 2007
    Messages:
    2,503
    Location:
    Sweden
    In light of this information we can't talk about fogbusting any longer, just as it was impossible to talk about the geocentrism of the universe when it was discovered that the sun is the center point in our planetary system.

    Perhaps we should call it spawnbusting henceforth but since that's actually a longer word I'm open to suggestions. Maybe barbusting? :)
     
  14. TheMeInTeam

    TheMeInTeam Top Logic

    Joined:
    Jan 26, 2008
    Messages:
    24,743
    Hump-catting...similar to bear-blasting!!!

    Wow, I didn't realize that the fog was irrelevant...just wow. That's REALLY helpful info danf...

    I often thought it strange, because on occasion I'd "risk" a warrior who was fortified on a hill near some terrain that was still fogged, but didn't want to contribute another unit to bust 1 tile. The term fogbusting is definitely misleading! I actually *was* busting those tiles, and never knew it. It seemed odd, but I just counted myself lucky :lol:.

    If I use this info I can often get away with busting away barbs with warriors alone on immortal more easily (I manage it in a lot of games already actually)...nice nice.
     
  15. Deckhand

    Deckhand Procrastination at its finest GOTM Staff

    Joined:
    Sep 22, 2008
    Messages:
    5,336
    Gender:
    Male
    Location:
    California
    Axe Axing
     
  16. Gliese 581

    Gliese 581 Your average civ junkie

    Joined:
    Oct 11, 2007
    Messages:
    2,503
    Location:
    Sweden
    Are barb cities also prevented from forming within two tiles of all units? I think no but maybe my memory is faulty on that, that is, prevented from having culture within 2 tiles after forming. Technically that's possible with 3 tiles away citiy-formations I suppose.
     
  17. TheMeInTeam

    TheMeInTeam Top Logic

    Joined:
    Jan 26, 2008
    Messages:
    24,743
    I really, really doubt cities can appear under conditions where units can't, but I've been wrong before.
     
  18. AndrewN

    AndrewN Chieftain

    Joined:
    Apr 28, 2003
    Messages:
    574
    Location:
    Stanwell, UK
    You need to go back and reread Dan's post :lol:, he specifically said in his post they can.

     
  19. Foamy7

    Foamy7 Mmm... Donuts...

    Joined:
    Apr 12, 2009
    Messages:
    102
    To summarize - cities can appear within 2 spaces of your units if and only if it is still fogged.

    Great info on this subject BTW - never knew any of this either!
     
  20. Yamps

    Yamps Chieftain

    Joined:
    Aug 30, 2007
    Messages:
    2,728
    Location:
    Zagreb, Croatia
    Another question:

    Is it possible to pop barb warriors from a hut at the very beginning of the game? If there are no barb animals at all before turn 5, I'm guessing that barb warriors can't pop so soon either. Is this true?
     

Share This Page