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

[BTS] First strikes are insane

Discussion in 'Civ4 - Strategy & Tips' started by earthy, Nov 5, 2019.

  1. gavenkoa

    gavenkoa Warlord

    Joined:
    Jun 11, 2019
    Messages:
    225
    Gender:
    Male
    Seems that @drewisfat is correct.

    Yes, I was mistaken that the number of first strikes is fixed.

    Count of first strikes is a combination of 2 things:

    Code:
         setCombatFirstStrikes((pCombatUnit->immuneToFirstStrikes()) ? 0 : (firstStrikes() + GC.getGameINLINE().getSorenRandNum(chanceFirstStrikes() + 1, "First Strike")));
    one fixed and one random in a range from 1 to some N.

    I tried to follow logic in code and it was hard to make definite conclusion, so I just bring reasonable explanation without pretending of its 100% correctness.

    CIV4UnitInfos.xml:

    Code:
    <UnitInfo>
      <Class>UNITCLASS_CROSSBOWMAN</Class>
      <Type>UNIT_CHINA_CHOKONU</Type>
      <bFirstStrikeImmune>0</bFirstStrikeImmune>
      <iFirstStrikes>2</iFirstStrikes>
      <iChanceFirstStrikes>0</iChanceFirstStrikes>
    
    <UnitInfo>
      <Class>UNITCLASS_MARINE</Class>
      <Type>UNIT_AMERICAN_NAVY_SEAL</Type>
      <bFirstStrikeImmune>0</bFirstStrikeImmune>
      <iFirstStrikes>1</iFirstStrikes>
      <iChanceFirstStrikes>1</iChanceFirstStrikes>
    
    <UnitInfo>
      <Class>UNITCLASS_CHARIOT</Class>
      <Type>UNIT_EGYPT_WARCHARIOT</Type>
      <bFirstStrikeImmune>1</bFirstStrikeImmune>
      <iFirstStrikes>0</iFirstStrikes>
      <iChanceFirstStrikes>0</iChanceFirstStrikes>
    
    CIV4PromotionInfos.xml:

    Code:
    
    <PromotionInfo>
      <Type>PROMOTION_DRILL1</Type>
      <bImmuneToFirstStrikes>0</bImmuneToFirstStrikes>
      <iFirstStrikesChange>0</iFirstStrikesChange>
      <iChanceFirstStrikesChange>1</iChanceFirstStrikesChange>
    <PromotionInfo>
      <Type>PROMOTION_DRILL2</Type>
      <bImmuneToFirstStrikes>0</bImmuneToFirstStrikes>
      <iFirstStrikesChange>1</iFirstStrikesChange>
      <iChanceFirstStrikesChange>0</iChanceFirstStrikesChange>
    <PromotionInfo>
      <Type>PROMOTION_DRILL3</Type>
      <bImmuneToFirstStrikes>0</bImmuneToFirstStrikes>
      <iFirstStrikesChange>0</iFirstStrikesChange>
      <iChanceFirstStrikesChange>2</iChanceFirstStrikesChange>
    <PromotionInfo>
      <Type>PROMOTION_DRILL4</Type>
      <bImmuneToFirstStrikes>0</bImmuneToFirstStrikes>
      <iFirstStrikesChange>2</iFirstStrikesChange>
      <iChanceFirstStrikesChange>0</iChanceFirstStrikesChange>
    
    So there is a fixed component and a variable component. getSorenRandNum(N+1) gives numbers 0, 1, ..., N with probability 1/(N+1).

    Drill 1 + 2 + 3 gives:
    fixed = 1
    variable = 1 + 2 = 3
    So distribution is 1 / 2 / 3 /4 (with equal probability of 25%).

    Drill 1+2+3+4 gives:
    fixed = 1+2 = 3
    variable = 1 + 2 = 3
    So distribution is 3 / 4 / 5 / 6 (with equal probability of 25%).
     

Share This Page