//==================================================================================================
//  Terran Melee Hard - Very Hard
//==================================================================================================

// very similar to Very Hard builds, but with minor deliberate delays/weakness

bool TerranOpenRushMarineHdVH (int player);                   // heavy early marine rush 
bool TerranOpenRushMarineReaperHdVH (int player);             // marine w/ early reaper harass
bool TerranOpenRushProxyBarracksHdVH (int player);            // proxy barracks marine rush
bool TerranOpenTimingMMStimHdVH (int player);                 // stim timing push
bool TerranOpenTimingHellionMarauderHdVH (int player);        // hellion marauder timing push
bool TerranOpenTimingMariSiegeHdVH (int player);              // marine + siege push
bool TerranOpenTimingCloakBansheeHdVH (int player);           // cloak banshee timing
bool TerranOpenPowerMacroQuickExpGndHdVH (int player);        // aggresive quick expand
bool TerranOpenPowerMacroMarineExpGndHdVH (int player);       // gasless marines expand
bool TerranOpenPowerMacroDefenseExpGndHdVH (int player);      // safer marine/siege expand
bool TerranOpenAirOneBaseAirHdVH (int player);                // single base "island" air build
bool TerranOpenAirOneBaseDropHdVH (int player);               // single base "island" drop build
bool TerranOpenAirCloakBansheeHdVH (int player);              // single base "island" cloak banshee
bool TerranOpenAirQuickExpandAirHdVH (int player);            // quick expand air build

bool TerranMidRushTimingMMMedivacHdVH (int player);           // continued agression with mmm
bool TerranMidRushTimingDefensiveExpandHdVH (int player);     // transition from early pressure to a macro game
bool TerranMidPowerMMMedivacHdVH (int player);                // standard bio attack
bool TerranMidPowerMMSiegeHdVH (int player);                  // bio+siege
bool TerranMidPowerSiegeBansheeHdVH (int player);             // delayed 1,1,1
bool TerranMidPowerHellionSiegeHdVH (int player);             // low-tech mech
bool TerranMidPowerSiegeThorHdVH (int player);                // high-tech mech
bool TerranMidMacroBioHdVH (int player);                      // macro toward late game bio
bool TerranMidMacroMechHdVH (int player);                     // macro toward late game mech
bool TerranMidMacroThorBCHdVH (int player);                   // macro toward late game thor/bc
bool TerranMidAirOneBaseAirHdVH (int player);                 // continue single base "island" air build
bool TerranMidAirOneBaseDropHdVH (int player);                // continue single base "island" drop build
bool TerranMidAirExpansionVikingBansheeHdVH (int player);     // quick expand viking/banshee attack
bool TerranMidAirExpansionBCHdVH (int player);                // quick expand battlecruiser attack
bool TerranMidAirExpansionDropAirHdVH (int player);           // quick expand drop + air attack
bool TerranMidAirMacroHdVH (int player);                      // macro toward a large late game air force

//--------------------------------------------------------------------------------------------------
//  TerranOpenHdVH
//--------------------------------------------------------------------------------------------------
void TerranOpenHdVH (int player) {
    bool done = false;
    int buildIndex;

    AIEarlyDefenseScouting(player);

    // see if we need to switch builds
    UpdateHDTerranOpening(player);
    
    buildIndex = AIGetUserInt(player, c_currentBuildIndex);
    if (buildIndex == e_hdBuildIndex_TOpenRush_Marine)                      { done = TerranOpenRushMarineHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TOpenRush_MarineReaper)           { done = TerranOpenRushMarineReaperHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TOpenRush_ProxyBarracks)          { done = TerranOpenRushProxyBarracksHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TOpenTiming_MMStim)               { done = TerranOpenTimingMMStimHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TOpenTiming_HellionMarauder)      { done = TerranOpenTimingHellionMarauderHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TOpenTiming_MariSiege)            { done = TerranOpenTimingMariSiegeHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TOpenTiming_CloakBanshee)         { done = TerranOpenTimingCloakBansheeHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TOpenPowerMacro_QuickExpGnd)      { done = TerranOpenPowerMacroQuickExpGndHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TOpenPowerMacro_MarineExpGnd)     { done = TerranOpenPowerMacroMarineExpGndHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TOpenPowerMacro_DefenseExpGnd)    { done = TerranOpenPowerMacroDefenseExpGndHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TOpenAir_OneBaseAir)              { done = TerranOpenAirOneBaseAirHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TOpenAir_OneBaseDrop)             { done = TerranOpenAirOneBaseDropHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TOpenAir_CloakBanshee)            { done = TerranOpenAirCloakBansheeHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TOpenAir_QuickExpandAir)          { done = TerranOpenAirQuickExpandAirHdVH (player); }
    else { ErrorMeleeScript(player, "Invalid Open BuildIndex TerranHdVH"); }

    if (done) {
        TerranHDInitMid(player); // Transition to MidGame
    }
}

//--------------------------------------------------------------------------------------------------
//  TerranMidHdVH
//--------------------------------------------------------------------------------------------------
void TerranMidHdVH (int player) {
    bool done = false;
    int buildIndex;
    
    // enable scouting as appropriate
    if (AIGetUserInt(player, c_numGroundStartLocs) > 0) {
        AIScoutingEnable(player, 15, c_TU_SCV);
        AIEarlyDefenseScouting(player);
    }
    else {
        AIScoutingEnable(player, 1, c_TU_Medivac);
    }

    // see if we need to switch builds
    UpdateHDTerranMidGame(player);
    
    buildIndex = AIGetUserInt(player, c_currentBuildIndex);
    if (buildIndex == e_hdBuildIndex_TMidRushTiming_MMMedivac)              { done = TerranMidRushTimingMMMedivacHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TMidRushTiming_DefensiveExpand)   { done = TerranMidRushTimingDefensiveExpandHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TMidPower_MMMedivac)              { done = TerranMidPowerMMMedivacHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TMidPower_MMSiege)                { done = TerranMidPowerMMSiegeHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TMidPower_SiegeBanshee)           { done = TerranMidPowerSiegeBansheeHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TMidPower_HellionSiege)           { done = TerranMidPowerHellionSiegeHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TMidPower_SiegeThor)              { done = TerranMidPowerSiegeThorHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TMidMacro_Bio)                    { done = TerranMidMacroBioHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TMidMacro_Mech)                   { done = TerranMidMacroMechHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TMidMacro_ThorBC)                 { done = TerranMidMacroThorBCHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TMidAir_OneBaseAir)               { done = TerranMidAirOneBaseAirHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TMidAir_OneBaseDrop)              { done = TerranMidAirOneBaseDropHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TMidAir_ExpansionVikingBanshee)   { done = TerranMidAirExpansionVikingBansheeHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TMidAir_ExpansionBC)              { done = TerranMidAirExpansionBCHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TMidAir_ExpansionDropAir)         { done = TerranMidAirExpansionDropAirHdVH (player); }
    else if (buildIndex == e_hdBuildIndex_TMidAir_Macro)                    { done = TerranMidAirMacroHdVH (player); }
    else { ErrorMeleeScript(player, "Invalid Mid BuildIndex TerranHdVH"); }

    if (done) {
        TerranHDInitLate(player); // Transition to LateGame
    }
}

//==================================================================================================
//  OPENINGS
//==================================================================================================

//--------------------------------------------------------------------------------------------------
//  TerranOpenRushMarineHdVH
//--------------------------------------------------------------------------------------------------
bool TerranOpenRushMarineHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 14, c_TU_SCV );
    AISetStock( player, 3, c_TB_Barracks );
    AISetStock( player, 15, c_TU_SCV );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 9, c_TU_Marine );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 15, c_TU_Marine );
    AISetStock( player, 20, c_TU_SCV );
    
    TerranBasicDefenseStock(player);
    TerranHDEmergencyDetectionAntiAir(player);

    AIEnableStock(player);

    //---------------------------------------------------------

    AIScoutingEnableWithPreReq(player, 12, c_TU_SCV, 1, c_TB_Barracks, c_techCountCompleteOnly);
    AISetAttackStatus(player, c_TU_Marine, 2, 9, c_continuousMerge);

    if (AIGetTime() < 300) {
        if ( (AITechCount(player, c_TU_Marine, c_techCountCompleteOnly) < 9) &&
             (AITechCount(player, c_TU_Marine, c_techCountInProgressOrBetter) < 12) ) {
                // wait for 9 to be done and 3 more queued
                return false;
        }
    }

    return true;  // Transition to MidGame
}

//--------------------------------------------------------------------------------------------------
//  TerranOpenRushMarineReaperHdVH
//--------------------------------------------------------------------------------------------------
bool TerranOpenRushMarineReaperHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 14, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 16, c_TU_SCV );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 2, c_TB_SupplyDepot );
    
    TerranBasicDefenseStock(player);

    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_BarracksTechLab );
    AISetStock( player, 19, c_TU_SCV );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TU_Reaper );
    AISetStock( player, 3, c_TU_Marine );
    AISetStock( player, 20, c_TU_SCV );    
    AISetStock( player, 3, c_TB_Barracks );
    AISetStock( player, 21, c_TU_SCV );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 2, c_TU_Reaper );
    AISetStock( player, 22, c_TU_SCV );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 6, c_TU_Marine );
    AISetStock( player, 3, c_TU_Reaper );
    AISetStock( player, 1, c_TR_MarineStimPack );
    AISetStock( player, 7, c_TU_Marine );
    AISetStock( player, 23, c_TU_SCV );
    AISetStock( player, 2, c_TB_Refinery );
    AISetStock( player, 24, c_TU_SCV );
    AISetStock( player, 8, c_TU_Marine );
    AISetStock( player, 4, c_TU_Reaper );
    AISetStock( player, 25, c_TU_SCV );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_BarracksTechLab );
    AISetStock( player, 10, c_TU_Marine );
    AISetStock( player, 5, c_TU_Reaper );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AIEnableStock(player);

    //---------------------------------------------------------

    AIScoutingEnableWithPreReq(player, 17, c_TU_SCV, 1, c_TB_OrbitalCommand, c_techCountInProgressOrBetter);
    AISetAttackStatus(player, c_TU_Marine, 2, 999, c_continuousMerge);
    AISetAttackStatus(player, c_TU_Reaper, 1, 3, c_continuousMerge);

    if (AIGetTime() < 390) {
        if (AITechCount(player, c_TU_Reaper, c_techCountCompleteOnly) < 4) {
            return false;
        }
    }

    return true;  // Transition to MidGame
}

//--------------------------------------------------------------------------------------------------
//  TerranOpenRushProxyBarracksHdVH
//--------------------------------------------------------------------------------------------------
bool TerranOpenRushProxyBarracksHdVH (int player) {

    // not yet a proxy build, needs to be fixed

    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );        // proxy
    AISetStock( player, 14, c_TU_SCV );
    AISetStock( player, 3, c_TB_Barracks );        // proxy
    AISetStock( player, 15, c_TU_SCV );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 9, c_TU_Marine );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 15, c_TU_Marine );
    AISetStock( player, 20, c_TU_SCV );
    
    TerranBasicDefenseStock(player);
    TerranHDEmergencyDetectionAntiAir(player);

    AIEnableStock(player);

    //---------------------------------------------------------

    AIScoutingEnableWithPreReq(player, 12, c_TU_SCV, 1, c_TB_Barracks, c_techCountCompleteOnly);
    AISetAttackStatus(player, c_TU_Marine, 2, 9, c_continuousMerge);

    if (AIGetTime() < 300) {
        if ( (AITechCount(player, c_TU_Marine, c_techCountCompleteOnly) < 9) ||
             (AITechCount(player, c_TU_Marine, c_techCountInProgressOrBetter) < 12) ) {
                 // wait for 9 to be done and 3 more queued
                return false;
        }
    }

    return true;  // Transition to MidGame
}

//--------------------------------------------------------------------------------------------------
//  TerranOpenTimingMMStimHdVH
//--------------------------------------------------------------------------------------------------
bool TerranOpenTimingMMStimHdVH (int player) {
    AIClearStock(player);

    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 14, c_TU_SCV );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 16, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 5, c_TU_Marine );
    
    TerranBasicDefenseStock(player);

    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 3, c_TB_Barracks );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 2, c_TB_BarracksTechLab );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    AISetStock( player, 6, c_TU_Marine );
    AISetStock( player, 1, c_TR_MarineStimPack );
    AISetStock( player, 7, c_TU_Marine );
    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TR_MarauderSlow );
    AISetStock( player, 10, c_TU_Marine );
    AISetStock( player, 21, c_TU_SCV );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 13, c_TU_Marine );
    AISetStock( player, 2, c_TU_Marauder );
    AISetStock( player, 14, c_TU_Marine );
    AISetStock( player, 1, c_TR_MarineShield );
    AISetStock( player, 6, c_TB_SupplyDepot );
    AISetStock( player, 4, c_TU_Marauder );
    AISetStock( player, 22, c_TU_SCV );
    AISetStock( player, 16, c_TU_Marine );
    AISetStock( player, 6, c_TU_Marauder );
    AISetStock( player, 17, c_TU_Marine );
    AISetStock( player, 7, c_TB_SupplyDepot );
    AISetStock( player, 24, c_TU_SCV );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AIEnableStock(player);

    //---------------------------------------------------------
    
    AIScoutingEnableWithPreReq(player, 12, c_TU_SCV, 1, c_TB_Barracks, c_techCountCompleteOnly);
    AISetAttackStatus(player, c_TU_Marine, 3, 999, c_continuousMerge);    
    if (AITechCount(player, c_TU_Marine, c_techCountCompleteOnly) >= 6) {
        AISetAttackStatus(player, c_TU_Marauder, 1, 2, c_continuousMerge);
    }
    
    if (AIGetTime() < 450) {
        if (AITechCount(player, c_TU_Marauder, c_techCountInProgressOrBetter) < 6) {
            return false;
        }
    }

    return true;  // Transition to MidGame
}

//--------------------------------------------------------------------------------------------------
//  TerranOpenTimingHellionMarauderHdVH
//--------------------------------------------------------------------------------------------------
bool TerranOpenTimingHellionMarauderHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 14, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 16, c_TU_SCV );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 3, c_TU_Marine );
    
    TerranBasicDefenseStock(player);

    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 1, c_TB_BarracksTechLab );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 19, c_TU_SCV );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 1, c_TU_Marauder );
    AISetStock( player, 1, c_TU_Hellion );
    AISetStock( player, 21, c_TU_SCV );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TR_MarauderSlow );
    AISetStock( player, 2, c_TU_Marauder );
    AISetStock( player, 2, c_TU_Hellion );
    AISetStock( player, 22, c_TU_SCV );
    AISetStock( player, 2, c_TB_BarracksTechLab );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 23, c_TU_SCV );
    AISetStock( player, 3, c_TU_Marauder );
    AISetStock( player, 3, c_TU_Hellion );
    AISetStock( player, 4, c_TU_Marauder );
    AISetStock( player, 24, c_TU_SCV );
    AISetStock( player, 6, c_TB_SupplyDepot );
    AISetStock( player, 6, c_TU_Marauder );
    AISetStock( player, 4, c_TU_Hellion );
    AISetStock( player, 25, c_TU_SCV );
    AISetStock( player, 7, c_TB_SupplyDepot );
    AISetStock( player, 8, c_TU_Marauder );
    AISetStock( player, 5, c_TU_Hellion );
    AISetStock( player, 26, c_TU_SCV );
    AISetStock( player, 10, c_TU_Marauder );
    AISetStock( player, 6, c_TU_Hellion );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AIEnableStock(player);

    //---------------------------------------------------------
    
    AIScoutingEnableWithPreReq(player, 12, c_TU_SCV, 1, c_TB_Barracks, c_techCountCompleteOnly);
    AISetAttackStatus(player, c_TU_Marine, 2, 999, c_continuousMerge);
    AISetAttackStatus(player, c_TU_Marauder, 2, 999, c_continuousMerge);
    AISetAttackStatus(player, c_TU_Hellion, 1, 4, c_continuousMerge);

    if (AIGetTime() < 440) {
        if (AITechCount(player, c_TU_Hellion, c_techCountInProgressOrBetter) < 5) {
            return false;
        }
    }
    
    if (AITechCount(player, c_TU_Marauder, c_techCountCompleteOnly) >= 4) {
        AISetAttackStatus(player, c_TU_Hellion, 1, 3, c_continuousMerge);
    }
    return true;  // Transition to MidGame
}

//--------------------------------------------------------------------------------------------------
//  TerranOpenTimingMariSiegeHdVH
//--------------------------------------------------------------------------------------------------
bool TerranOpenTimingMariSiegeHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 14, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 16, c_TU_SCV );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TU_Marine );
    
    TerranBasicDefenseStock(player);

    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 3, c_TU_Marine );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    AISetStock( player, 2, c_TB_Refinery );
    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 5, c_TU_Marine );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 21, c_TU_SCV );
    AISetStock( player, 1, c_TB_FactoryTechLab );
    AISetStock( player, 6, c_TU_Marine );
    AISetStock( player, 23, c_TU_SCV );
    AISetStock( player, 1, c_TU_SiegeTank );
    AISetStock( player, 7, c_TU_Marine );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 24, c_TU_SCV );
    AISetStock( player, 8, c_TU_Marine );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TU_SiegeTank );
    AISetStock( player, 9, c_TU_Marine );
    AISetStock( player, 25, c_TU_SCV );
    AISetStock( player, 10, c_TU_Marine );
    AISetStock( player, 26, c_TU_SCV );
    AISetStock( player, 6, c_TB_SupplyDepot );
    AISetStock( player, 3, c_TU_SiegeTank );
    AISetStock( player, 12, c_TU_Marine );
    AISetStock( player, 28, c_TU_SCV );
    AISetStock( player, 7, c_TB_SupplyDepot );
    AISetStock( player, 14, c_TU_Marine );
    AISetStock( player, 29, c_TU_SCV );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AIEnableStock(player);

    //---------------------------------------------------------
    
    AIScoutingEnableWithPreReq(player, 12, c_TU_SCV, 1, c_TB_Barracks, c_techCountCompleteOnly);
    AISetAttackStatus(player, c_TU_Marine, 2, 999, c_continuousMerge);
    AISetAttackStatus(player, c_TU_SiegeTank, 1, 2, c_continuousMerge);

    if (AIGetTime() < 420) {
        if (AITechCount(player, c_TU_SiegeTank, c_techCountInProgressOrBetter) < 3) {
            return false;
        }
    }

    return true;  // Transition to MidGame
}

//--------------------------------------------------------------------------------------------------
//  TerranOpenTimingCloakBansheeHdVH
//--------------------------------------------------------------------------------------------------
bool TerranOpenTimingCloakBansheeHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 14, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    
    TerranBasicDefenseStock(player);

    AISetStock( player, 15, c_TU_SCV );
    AISetStock( player, 2, c_TB_Refinery );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TB_Starport );
    AISetStock( player, 19, c_TU_SCV );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_StarportTechLab );
    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 2, c_TU_Banshee );
    AISetStock( player, 1, c_TR_BansheeCloak );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 4, c_TU_Banshee );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 21, c_TU_SCV );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 22, c_TU_SCV );
    AISetStock( player, 3, c_TU_Marine );
    AISetStock( player, 6, c_TU_Banshee );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 24, c_TU_SCV );
    AISetStock( player, 7, c_TU_Marine );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AIEnableStock(player);

    //---------------------------------------------------------
    
    // attack is done by diversion wave with banshees
    if (AITechCount(player, c_TU_Banshee, c_techCountCompleteOnly) >= 2) {
        AISetFlag(player, e_flagsDiversion, true);
    }
    
    AIScoutingEnableWithPreReq(player, 16, c_TU_SCV, 1, c_TB_Barracks, c_techCountCompleteOnly);
    if (AIGetTime() < 510) {
        if (AITechCount(player, c_TU_Banshee, c_techCountInProgressOrBetter) < 6) {
            return false;
        }
    }

    return true;  // Transition to MidGame
}

//--------------------------------------------------------------------------------------------------
//  TerranOpenPowerMacroQuickExpGndHdVH
//--------------------------------------------------------------------------------------------------
bool TerranOpenPowerMacroQuickExpGndHdVH (int player) {
    AIClearStock(player);

    // riskier very fast expansion
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 14, c_TU_SCV );
    
    TerranBasicDefenseStock(player);

    if (AITechCount(player, c_TU_SCV, c_techCountQueuedOrBetter) >= 14) {
        if (TerranHDFastExpand(player)) { return false; }
    }

    AISetStock( player, 15, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 3, c_TU_Marine );
    AISetStock( player, 1, c_TB_Refinery );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AIEnableStock(player);

    //---------------------------------------------------------
    
    AIScoutingEnableWithPreReq(player, 18, c_TU_SCV, 1, c_TB_Barracks, c_techCountCompleteOnly);
    if (AIGetTime() < 270) {
        if (AITechCount(player, c_TB_CommandCenter_Alias, c_techCountInProgressOrBetter) < 2) {
            return false;
        }
    }

    return true;  // Transition to MidGame
}

//--------------------------------------------------------------------------------------------------
//  TerranOpenPowerMacroMarineExpGndHdVH
//--------------------------------------------------------------------------------------------------
bool TerranOpenPowerMacroMarineExpGndHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    
    TerranBasicDefenseStock(player);

    AISetStock( player, 16, c_TU_SCV );

    if (AITechCount(player, c_TU_SCV, c_techCountInProgressOrBetter) >= 16) {
        if (TerranHDFastExpand(player)) { return false; }
    }
    
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 3, c_TU_Marine );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    AISetStock( player, 5, c_TU_Marine );
    AISetStock( player, 20, c_TU_SCV );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AIEnableStock(player);

    //---------------------------------------------------------
    
    AIScoutingEnableWithPreReq(player, 18, c_TU_SCV, 1, c_TB_Barracks, c_techCountCompleteOnly);
    if (AIGetTime() < 300) {
        if (AITechCount(player, c_TB_CommandCenter_Alias, c_techCountInProgressOrBetter) < 2) {
            return false;
        }
    }

    return true;  // Transition to MidGame
}

//--------------------------------------------------------------------------------------------------
//  TerranOpenPowerMacroDefenseExpGndHdVH
//--------------------------------------------------------------------------------------------------
bool TerranOpenPowerMacroDefenseExpGndHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 14, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 16, c_TU_SCV );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 3, c_TU_Marine );
    
    TerranBasicDefenseStock(player);

    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 19, c_TU_SCV );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 5, c_TU_Marine );
    AISetStock( player, 21, c_TU_SCV );
    AISetStock( player, 6, c_TU_Marine );
    AISetStock( player, 22, c_TU_SCV );
    
    if (AITechCount(player, c_TU_SCV, c_techCountQueuedOrBetter) >= 22) {
        if (TerranHDFastExpand(player)) { return false; }
    }

    AISetStock( player, 1, c_TB_FactoryTechLab );
    AISetStock( player, 23, c_TU_SCV );
    AISetStock( player, 7, c_TU_Marine );
    AISetStock( player, 2, c_TB_Refinery );
    AISetStock( player, 1, c_TU_SiegeTank );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 24, c_TU_SCV );
    AISetStock( player, 8, c_TU_Marine );
    AISetStock( player, 1, c_TR_SiegeTankSiege );
    AISetStock( player, 25, c_TU_SCV );
    AISetStock( player, 2, c_TU_SiegeTank );
    AISetStock( player, 9, c_TU_Marine );
    AISetStock( player, 26, c_TU_SCV );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AIEnableStock(player);

    //---------------------------------------------------------
    
    AIScoutingEnableWithPreReq(player, 18, c_TU_SCV, 1, c_TB_Barracks, c_techCountCompleteOnly);
    if (AIGetTime() < 360) {
        if (AITechCount(player, c_TR_SiegeTankSiege, c_techCountInProgressOrBetter) < 1) {
            return false;
        }
    }

    return true;  // Transition to MidGame
}

//--------------------------------------------------------------------------------------------------
//  TerranOpenAirOneBaseAirHdVH
//--------------------------------------------------------------------------------------------------
bool TerranOpenAirOneBaseAirHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 13, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    
    TerranBasicDefenseStock(player);

    AISetStock( player, 15, c_TU_SCV );
    AISetStock( player, 2, c_TB_Refinery );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    AISetStock( player, 2, c_TB_Starport );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 2, c_TU_Viking );
    AISetStock( player, 22, c_TU_SCV );
    AISetStock( player, 4, c_TU_Viking );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 23, c_TU_SCV );
    AISetStock( player, 6, c_TU_Viking );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 25, c_TU_SCV );
    AISetStock( player, 8, c_TU_Viking );
    AISetStock( player, 6, c_TB_SupplyDepot );
    AISetStock( player, 3, c_TU_Marine );
    AISetStock( player, 26, c_TU_SCV );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AIEnableStock(player);

    //---------------------------------------------------------

    AISetAttackStatus(player, c_TU_Viking_Alias, 2, 6, c_continuousMerge);
    
    if (AIGetTime() < 480) {
        if (AITechCount(player, c_TU_Viking_Alias, c_techCountCompleteOnly) < 8) {
            return false;
        }
    }

    return true;  // Transition to MidGame
}

//--------------------------------------------------------------------------------------------------
//  TerranOpenAirOneBaseDropHdVH
//--------------------------------------------------------------------------------------------------
bool TerranOpenAirOneBaseDropHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 13, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    
    TerranBasicDefenseStock(player);

    AISetStock( player, 15, c_TU_SCV );
    AISetStock( player, 2, c_TB_Refinery );
    AISetStock( player, 16, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 1, c_TB_BarracksReactor );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_Starport );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 6, c_TU_Marine );
    AISetStock( player, 1, c_TU_Medivac );
    AISetStock( player, 8, c_TU_Marine );
    AISetStock( player, 2, c_TB_Starport );
    AISetStock( player, 2, c_TU_Medivac );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 10, c_TU_Marine );
    AISetStock( player, 2, c_TU_Viking );
    AISetStock( player, 12, c_TU_Marine );
    AISetStock( player, 22, c_TU_SCV );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 16, c_TU_Marine );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AIEnableStock(player);

    //---------------------------------------------------------

    if (AITechCount(player, c_TU_Medivac, c_techCountCompleteOnly) >= 2) {
        AISetAttackStatus(player, c_TU_Marine, 6, 10, c_continuousMerge);
    }
    
    if (AIGetTime() < 480) {
        if (AITechCount(player, c_TU_Viking, c_techCountCompleteOnly) < 2) {
            return false;
        }
    }

    return true;  // Transition to MidGame
}

//--------------------------------------------------------------------------------------------------
//  TerranOpenAirCloakBansheeHdVH
//--------------------------------------------------------------------------------------------------
bool TerranOpenAirCloakBansheeHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 14, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    
    TerranBasicDefenseStock(player);

    AISetStock( player, 15, c_TU_SCV );
    AISetStock( player, 2, c_TB_Refinery );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TB_Starport );
    AISetStock( player, 19, c_TU_SCV );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_StarportTechLab );
    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 2, c_TU_Banshee );
    AISetStock( player, 1, c_TR_BansheeCloak );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 4, c_TU_Banshee );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 21, c_TU_SCV );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 22, c_TU_SCV );
    AISetStock( player, 3, c_TU_Marine );
    AISetStock( player, 6, c_TU_Banshee );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 24, c_TU_SCV );
    AISetStock( player, 7, c_TU_Marine );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AIEnableStock(player);

    //---------------------------------------------------------
    
    // attack is done by diversion wave with banshees
    if (AITechCount(player, c_TU_Banshee, c_techCountCompleteOnly) >= 2) {
        AISetFlag(player, e_flagsDiversion, true);
    }

    if (AIGetTime() < 510) {
        if (AITechCount(player, c_TU_Banshee, c_techCountInProgressOrBetter) < 6) {
            return false;
        }
    }

    return true;  // Transition to MidGame
}

//--------------------------------------------------------------------------------------------------
//  TerranOpenAirQuickExpandAirHdVH
//--------------------------------------------------------------------------------------------------
bool TerranOpenAirQuickExpandAirHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 15, c_TU_SCV );
    
    TerranBasicDefenseStock(player);

    if (AITechCount(player, c_TU_SCV, c_techCountQueuedOrBetter) >= 15) {
        if (TerranHDFastExpand(player)) { return false; }
    }

    AISetStock( player, 16, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AIEnableStock(player);
    
    if (AIGetTime() < 240) {
        if (AITechCount(player, c_TB_CommandCenter_Alias, c_techCountInProgressOrBetter) < 2) {
            return false;
        }
    }

    return true;  // Transition to MidGame
}

//==================================================================================================
//  MID GAME
//==================================================================================================

//--------------------------------------------------------------------------------------------------
//  TerranMidRushTimingMMMedivacHdVH
//--------------------------------------------------------------------------------------------------
bool TerranMidRushTimingMMMedivacHdVH (int player) {
    AIClearStock(player);

    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 14, c_TU_SCV );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 16, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 5, c_TU_Marine );
    
    TerranBasicDefenseStock(player);

    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 2, c_TB_Refinery );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 7, c_TU_Marine );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AISetStock( player, 1, c_TB_BarracksTechLab );
    AISetStock( player, 8, c_TU_Marine );
    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 9, c_TU_Marine );
    AISetStock( player, 1, c_TR_MarineStimPack );
    AISetStock( player, 10, c_TU_Marine );
    AISetStock( player, 21, c_TU_SCV );
    AISetStock( player, 1, c_TB_Starport );
    AISetStock( player, 22, c_TU_SCV );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_Marine );
    AISetStock( player, 23, c_TU_SCV );
    AISetStock( player, 14, c_TU_Marine );
    AISetStock( player, 24, c_TU_SCV );
    AISetStock( player, 1, c_TU_Medivac );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_BarracksTechLab );
    AISetStock( player, 1, c_TU_Marauder );
    AISetStock( player, 2, c_TU_Medivac );
    AISetStock( player, 2, c_TU_Marauder );
    AISetStock( player, 6, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TR_MarineShield );
    AISetStock( player, 3, c_TU_Marauder );
    AISetStock( player, 25, c_TU_SCV );
    AISetStock( player, 2, c_TB_EngineeringBay );
    AISetStock( player, 5, c_TU_Marauder );
    AISetStock( player, 3, c_TU_Medivac );
    AISetStock( player, 7, c_TB_SupplyDepot );
    AISetStock( player, 26, c_TU_SCV );

    TerranHDDefaultExtraMidStock(player);

    AIEnableStock(player);

    //---------------------------------------------------------

    AISetAttackStatus(player, c_TU_Marine, 4, 999, c_continuousMerge);
    AISetAttackStatus(player, c_TU_Marauder, 4, 999, c_continuousMerge);
    if (AITechCount(player, c_TU_Marauder, c_techCountCompleteOnly) >= 3) {
        AISetAttackStatus(player, c_TU_Medivac, 1, 2, c_continuousMerge);
    }
    
    if (AIGetTime() < 510) {
        if (AITechCount(player, c_TU_Medivac, c_techCountInProgressOrBetter) < 3) {
            return false;
        }
    }

    return true;  // Transition to LateGame
}

//--------------------------------------------------------------------------------------------------
//  TerranMidRushTimingDefensiveExpandHdVH
//--------------------------------------------------------------------------------------------------
bool TerranMidRushTimingDefensiveExpandHdVH (int player) {
    AIClearStock(player);

    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 14, c_TU_SCV );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 16, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 3, c_TU_Marine );
    
    TerranBasicDefenseStock(player);

    AISetStock( player, 1, c_TB_BarracksTechLab );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 6, c_TU_Marine );
    AISetStock( player, 19, c_TU_SCV );
    AISetStock( player, 1, c_TR_MarineStimPack );
    AISetStock( player, 8, c_TU_Marine );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 10, c_TU_Marine );
    AISetStock( player, 21, c_TU_SCV );
    
    if (AITechCount(player, c_TU_SCV, c_techCountQueuedOrBetter) >= 21) {
        if (TerranHDFastExpand(player)) { return false; }
    }
    
    TerranHDDefaultExtraMidStock(player);
    
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 22, c_TU_SCV );
    AISetStock( player, 12, c_TU_Marine );
    AISetStock( player, 23, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 24, c_TU_SCV );
    AISetStock( player, 1, c_TB_BarracksTechLab );
    AISetStock( player, 1, c_TU_Marauder );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 25, c_TU_SCV );
    AISetStock( player, 2, c_TB_Refinery );
    AISetStock( player, 2, c_TU_Marauder );
    AISetStock( player, 1, c_TR_MarauderSlow );
    AISetStock( player, 26, c_TU_SCV );
    AISetStock( player, 6, c_TB_SupplyDepot );
    AISetStock( player, 3, c_TU_Marauder );
    AISetStock( player, 28, c_TU_SCV );
    AISetStock( player, 1, c_TB_FactoryTechLab );
    
    if (AITechCount(player, c_TB_CommandCenter_Alias, c_techCountCompleteOnly) >= 2) {
        AISetStock( player, 2, c_TB_OrbitalCommand );
    }

    AISetStock( player, 4, c_TU_Marauder );
    AISetStock( player, 30, c_TU_SCV );
    AISetStock( player, 7, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TU_SiegeTank );
    AISetStock( player, 14, c_TU_Marine );
    AISetStock( player, 32, c_TU_SCV );
    AISetStock( player, 8, c_TB_SupplyDepot );
    AISetStock( player, 34, c_TU_SCV );
    AISetStock( player, 2, c_TU_SiegeTank );
    AISetStock( player, 4, c_TU_Marauder );
    AISetStock( player, 36, c_TU_SCV );

    AIEnableStock(player);

    //---------------------------------------------------------
    
    if (AIGetTime() < 510) {
        if (AITechCount(player, c_TU_SiegeTank, c_techCountInProgressOrBetter) < 2) {
            return false;
        }
    }

    return true;  // Transition to LateGame
}

//--------------------------------------------------------------------------------------------------
//  TerranMidPowerMMMedivacHdVH
//--------------------------------------------------------------------------------------------------
bool TerranMidPowerMMMedivacHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 16, c_TU_SCV );
    
    TerranBasicDefenseStock(player);

    if (AITechCount(player, c_TU_SCV, c_techCountInProgressOrBetter) >= 16) {
        if (TerranHDFastExpand(player)) { return false; }
    }
    
    TerranHDDefaultExtraMidStock(player);
    
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 3, c_TU_Marine );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    
    if (AITechCount(player, c_TB_CommandCenter_Alias, c_techCountCompleteOnly) >= 2) {
        AISetStock( player, 2, c_TB_OrbitalCommand );
    }

    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 5, c_TU_Marine );
    AISetStock( player, 21, c_TU_SCV );
    AISetStock( player, 6, c_TU_Marine );
    AISetStock( player, 2, c_TB_Refinery );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AISetStock( player, 23, c_TU_SCV );
    AISetStock( player, 8, c_TU_Marine );
    AISetStock( player, 25, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 10, c_TU_Marine );
    AISetStock( player, 27, c_TU_SCV );
    AISetStock( player, 3, c_TB_Barracks );
    AISetStock( player, 2, c_TB_BarracksTechLab );
    AISetStock( player, 29, c_TU_SCV );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 3, c_TB_Refinery );
    AISetStock( player, 31, c_TU_SCV );
    AISetStock( player, 2, c_TU_Marauder );
    AISetStock( player, 1, c_TB_Starport );
    AISetStock( player, 1, c_TB_FactoryTechLab );
    AISetStock( player, 33, c_TU_SCV );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 4, c_TU_Marauder );
    AISetStock( player, 11, c_TU_Marine );
    AISetStock( player, 35, c_TU_SCV );
    AISetStock( player, 6, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TU_SiegeTank );
    AISetStock( player, 4, c_TB_Refinery );
    AISetStock( player, 14, c_TU_Marine );
    AISetStock( player, 7, c_TB_SupplyDepot );
    AISetStock( player, 37, c_TU_SCV );
    AISetStock( player, 1, c_TU_Medivac );
    AISetStock( player, 8, c_TB_SupplyDepot );
    AISetStock( player, 14, c_TU_Marine );
    AISetStock( player, 39, c_TU_SCV );
    AISetStock( player, 9, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TU_SiegeTank );
    AISetStock( player, 2, c_TU_Medivac );
    AISetStock( player, 41, c_TU_SCV );
    AISetStock( player, 10, c_TB_SupplyDepot );
    AISetStock( player, 17, c_TU_Marine );
    AISetStock( player, 1, c_TR_MarineStimPack );
    AISetStock( player, 43, c_TU_SCV );
    AISetStock( player, 11, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TR_MarineShield );
    AISetStock( player, 20, c_TU_Marine );
    AISetStock( player, 2, c_TB_EngineeringBay );
    AISetStock( player, 45, c_TU_SCV );
    AISetStock( player, 12, c_TB_SupplyDepot );
    AISetStock( player, 3, c_TU_SiegeTank );
    AISetStock( player, 3, c_TU_Medivac );
    AISetStock( player, 47, c_TU_SCV );
    AISetStock( player, 6, c_TU_Marauder );
    AISetStock( player, 13, c_TB_SupplyDepot );
    AISetStock( player, 49, c_TU_SCV );

    AIEnableStock(player);

    //---------------------------------------------------------

    AISetAttackStatus(player, c_TU_Marine, 4, 999, c_continuousMerge);  
    AISetAttackStatus(player, c_TU_Marauder, 2, 999, c_continuousMerge);   
    if (AITechCount(player, c_TU_Marine, c_techCountCompleteOnly) >= 12) {
        if (AITechCount(player, c_TU_SiegeTank, c_techCountCompleteOnly) >= 1) {
            AISetAttackStatus(player, c_TU_Medivac, 1, 2, c_continuousMerge);
        }
    }
    
    if (AIGetTime() < 630) {
        if (AITechCount(player, c_TU_Medivac, c_techCountInProgressOrBetter) < 3) {
            return false;
        }
    }

    return true;  // Transition to LateGame
}

//--------------------------------------------------------------------------------------------------
//  TerranMidPowerMMSiegeHdVH
//--------------------------------------------------------------------------------------------------
bool TerranMidPowerMMSiegeHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 16, c_TU_SCV );
    
    TerranBasicDefenseStock(player);

    if (AITechCount(player, c_TU_SCV, c_techCountInProgressOrBetter) >= 16) {
        if (TerranHDFastExpand(player)) { return false; }
    }
    
    TerranHDDefaultExtraMidStock(player);
    
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 3, c_TU_Marine );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    
    if (AITechCount(player, c_TB_CommandCenter_Alias, c_techCountCompleteOnly) >= 2) {
        AISetStock( player, 2, c_TB_OrbitalCommand );
    }

    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 5, c_TU_Marine );
    AISetStock( player, 21, c_TU_SCV );
    AISetStock( player, 6, c_TU_Marine );
    AISetStock( player, 2, c_TB_Refinery );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AISetStock( player, 23, c_TU_SCV );
    AISetStock( player, 8, c_TU_Marine );
    AISetStock( player, 25, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 10, c_TU_Marine );
    AISetStock( player, 27, c_TU_SCV );
    AISetStock( player, 3, c_TB_Barracks );
    AISetStock( player, 29, c_TU_SCV );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_BarracksTechLab );
    AISetStock( player, 3, c_TB_Refinery );
    AISetStock( player, 31, c_TU_SCV );
    AISetStock( player, 2, c_TU_Marauder );
    AISetStock( player, 33, c_TU_SCV );
    AISetStock( player, 1, c_TB_FactoryTechLab );
    AISetStock( player, 2, c_TB_Factory );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 35, c_TU_SCV );
    AISetStock( player, 6, c_TB_SupplyDepot );
    AISetStock( player, 11, c_TU_Marine );
    AISetStock( player, 1, c_TU_SiegeTank );
    AISetStock( player, 37, c_TU_SCV );
    AISetStock( player, 7, c_TB_SupplyDepot );
    AISetStock( player, 14, c_TU_Marine );
    AISetStock( player, 39, c_TU_SCV );
    AISetStock( player, 7, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_FactoryTechLab );
    AISetStock( player, 8, c_TB_SupplyDepot );
    AISetStock( player, 41, c_TU_SCV );
    AISetStock( player, 4, c_TU_Marauder );
    AISetStock( player, 15, c_TU_Marine );
    AISetStock( player, 2, c_TU_SiegeTank );
    AISetStock( player, 1, c_TR_MarineStimPack );
    AISetStock( player, 9, c_TB_SupplyDepot );
    AISetStock( player, 43, c_TU_SCV );
    AISetStock( player, 3, c_TU_SiegeTank );
    AISetStock( player, 10, c_TB_SupplyDepot );
    AISetStock( player, 6, c_TU_Marauder );
    AISetStock( player, 17, c_TU_Marine );
    AISetStock( player, 11, c_TB_SupplyDepot );
    AISetStock( player, 45, c_TU_SCV );
    AISetStock( player, 4, c_TU_SiegeTank );
    AISetStock( player, 20, c_TU_Marine );
    AISetStock( player, 12, c_TB_SupplyDepot );
    AISetStock( player, 47, c_TU_SCV );
    AISetStock( player, 5, c_TU_SiegeTank );

    AIEnableStock(player);

    //---------------------------------------------------------

    AISetAttackStatus(player, c_TU_Marine, 4, 999, c_continuousMerge);
    AISetAttackStatus(player, c_TU_Marauder, 2, 999, c_continuousMerge);
    if (AITechCount(player, c_TU_Marine, c_techCountCompleteOnly) >= 12) {
        AISetAttackStatus(player, c_TU_SiegeTank_Alias, 1, 2, c_continuousMerge);
    }
    
    if (AIGetTime() < 540) {
        if (AITechCount(player, c_TU_SiegeTank_Alias, c_techCountInProgressOrBetter) < 4) {
            return false;
        }
    }

    return true;  // Transition to LateGame
}

//--------------------------------------------------------------------------------------------------
//  TerranMidPowerSiegeBansheeHdVH
//--------------------------------------------------------------------------------------------------
bool TerranMidPowerSiegeBansheeHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 16, c_TU_SCV );
    
    TerranBasicDefenseStock(player);

    if (AITechCount(player, c_TU_SCV, c_techCountInProgressOrBetter) >= 16) {
        if (TerranHDFastExpand(player)) { return false; }
    }
    
    TerranHDDefaultExtraMidStock(player);
    
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 3, c_TU_Marine );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    
    if (AITechCount(player, c_TB_CommandCenter_Alias, c_techCountCompleteOnly) >= 2) {
        AISetStock( player, 2, c_TB_OrbitalCommand );
    }

    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 5, c_TU_Marine );
    AISetStock( player, 21, c_TU_SCV );
    AISetStock( player, 6, c_TU_Marine );
    AISetStock( player, 2, c_TB_Refinery );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AISetStock( player, 23, c_TU_SCV );
    AISetStock( player, 8, c_TU_Marine );
    AISetStock( player, 25, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 4, c_TB_Refinery );
    AISetStock( player, 27, c_TU_SCV );
    AISetStock( player, 10, c_TU_Marine );
    AISetStock( player, 29, c_TU_SCV );
    AISetStock( player, 3, c_TB_Barracks );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 31, c_TU_SCV );
    AISetStock( player, 1, c_TB_Starport );
    AISetStock( player, 1, c_TB_FactoryTechLab );
    AISetStock( player, 33, c_TU_SCV );
    AISetStock( player, 6, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_Marine );
    AISetStock( player, 35, c_TU_SCV );
    AISetStock( player, 1, c_TU_SiegeTank );
    AISetStock( player, 15, c_TU_Marine );
    AISetStock( player, 7, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TB_StarportTechLab );
    AISetStock( player, 37, c_TU_SCV );
    AISetStock( player, 8, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_BarracksTechLab );
    AISetStock( player, 1, c_TU_Banshee );
    AISetStock( player, 1, c_TR_BansheeCloak );
    AISetStock( player, 39, c_TU_SCV );
    AISetStock( player, 16, c_TU_Marine );
    AISetStock( player, 10, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TU_SiegeTank );
    AISetStock( player, 41, c_TU_SCV );
    AISetStock( player, 2, c_TU_Marauder );
    AISetStock( player, 1, c_TR_MarineStimPack );
    AISetStock( player, 1, c_TR_MarineShield );
    AISetStock( player, 12, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_EngineeringBay );
    AISetStock( player, 17, c_TU_Marine );
    AISetStock( player, 2, c_TU_Banshee );
    AISetStock( player, 43, c_TU_SCV );
    AISetStock( player, 3, c_TU_SiegeTank );
    AISetStock( player, 3, c_TU_Banshee );
    AISetStock( player, 4, c_TU_Marauder );
    AISetStock( player, 18, c_TU_Marine );
    AISetStock( player, 45, c_TU_SCV );
    AISetStock( player, 14, c_TB_SupplyDepot );
    AISetStock( player, 6, c_TU_Marauder );
    AISetStock( player, 19, c_TU_Marine );
    AISetStock( player, 4, c_TU_SiegeTank );
    AISetStock( player, 4, c_TU_Banshee );
    AISetStock( player, 47, c_TU_SCV );
    AISetStock( player, 16, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TR_InfantryWeapons1 );
    AISetStock( player, 1, c_TR_InfantryArmor1 );
    AISetStock( player, 5, c_TU_SiegeTank );
    AISetStock( player, 5, c_TU_Banshee );
    AISetStock( player, 49, c_TU_SCV );
    AISetStock( player, 8, c_TU_Marauder );
    AISetStock( player, 20, c_TU_Marine );
    AISetStock( player, 18, c_TB_SupplyDepot );

    AIEnableStock(player);

    //---------------------------------------------------------

    AISetAttackStatus(player, c_TU_Marine, 4, 999, c_continuousMerge);
    AISetAttackStatus(player, c_TU_Marauder, 2, 999, c_continuousMerge);
    if (AITechCount(player, c_TU_Marine, c_techCountCompleteOnly) >= 14) {
        AISetAttackStatus(player, c_TU_SiegeTank_Alias, 1, 4, c_continuousMerge);
    }
    
    if (AIGetTime() < 690) {
        if (AITechCount(player, c_TU_SiegeTank_Alias, c_techCountInProgressOrBetter) < 5) {
            return false;
        }
    }

    return true;  // Transition to LateGame
}

//--------------------------------------------------------------------------------------------------
//  TerranMidPowerHellionSiegeHdVH
//--------------------------------------------------------------------------------------------------
bool TerranMidPowerHellionSiegeHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 16, c_TU_SCV );
    
    TerranBasicDefenseStock(player);

    if (AITechCount(player, c_TU_SCV, c_techCountInProgressOrBetter) >= 16) {
        if (TerranHDFastExpand(player)) { return false; }
    }
    
    TerranHDDefaultExtraMidStock(player);
    
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 3, c_TU_Marine );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    
    if (AITechCount(player, c_TB_CommandCenter_Alias, c_techCountCompleteOnly) >= 2) {
        AISetStock( player, 2, c_TB_OrbitalCommand );
    }

    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 5, c_TU_Marine );
    AISetStock( player, 21, c_TU_SCV );
    AISetStock( player, 6, c_TU_Marine );
    AISetStock( player, 2, c_TB_Refinery );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AISetStock( player, 23, c_TU_SCV );
    AISetStock( player, 8, c_TU_Marine );
    AISetStock( player, 25, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 3, c_TB_Refinery );
    AISetStock( player, 27, c_TU_SCV );
    AISetStock( player, 10, c_TU_Marine );
    AISetStock( player, 2, c_TB_Factory );
    AISetStock( player, 29, c_TU_SCV );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_Marine );
    AISetStock( player, 31, c_TU_SCV );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TB_FactoryTechLab );
    AISetStock( player, 14, c_TU_Marine );
    AISetStock( player, 33, c_TU_SCV );
    AISetStock( player, 1, c_TB_FactoryReactor );
    AISetStock( player, 7, c_TB_SupplyDepot );
    AISetStock( player, 4, c_TB_Refinery );
    AISetStock( player, 35, c_TU_SCV );
    AISetStock( player, 1, c_TU_SiegeTank );
    AISetStock( player, 3, c_TB_Factory );
    AISetStock( player, 37, c_TU_SCV );
    AISetStock( player, 8, c_TB_SupplyDepot );
    AISetStock( player, 39, c_TU_SCV );
    AISetStock( player, 2, c_TU_Hellion_Alias );
    AISetStock( player, 2, c_TU_SiegeTank );
    AISetStock( player, 4, c_TB_Factory );
    AISetStock( player, 2, c_TB_Armory );
    AISetStock( player, 41, c_TU_SCV );
    AISetStock( player, 4, c_TU_Hellion_Alias );
    AISetStock( player, 10, c_TB_SupplyDepot );
    AISetStock( player, 43, c_TU_SCV );
    AISetStock( player, 2, c_TB_FactoryTechLab );
    AISetStock( player, 3, c_TU_SiegeTank );
    AISetStock( player, 45, c_TU_SCV );
    AISetStock( player, 6, c_TU_Hellion_Alias );
    AISetStock( player, 5, c_TU_SiegeTank );
    AISetStock( player, 1, c_TR_VehicleWeapons1 );
    AISetStock( player, 1, c_TR_MechPlating1 );
    AISetStock( player, 47, c_TU_SCV );
    AISetStock( player, 7, c_TU_Hellion_Alias );
    AISetStock( player, 12, c_TB_SupplyDepot );
    AISetStock( player, 49, c_TU_SCV );
    AISetStock( player, 6, c_TU_SiegeTank );
    AISetStock( player, 10, c_TU_Hellion_Alias );
    AISetStock( player, 7, c_TU_SiegeTank );
    AISetStock( player, 51, c_TU_SCV );

    AIEnableStock(player);

    //---------------------------------------------------------
    
    AISetAttackStatus(player, c_TU_Marine, 4, 999, c_continuousMerge);
    if (AITechCount(player, c_TU_Marine, c_techCountCompleteOnly) >= 12) {
        AISetAttackStatus(player, c_TU_SiegeTank_Alias, 1, 5, c_continuousMerge);
    }

    if (AIGetTime() < 660) {
        if (AITechCount(player, c_TU_SiegeTank, c_techCountInProgressOrBetter) < 7) {
            return false;
        }
    }

    return true;  // Transition to LateGame
}

//--------------------------------------------------------------------------------------------------
//  TerranMidPowerSiegeThorHdVH
//--------------------------------------------------------------------------------------------------
bool TerranMidPowerSiegeThorHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 16, c_TU_SCV );
    
    TerranBasicDefenseStock(player);

    if (AITechCount(player, c_TU_SCV, c_techCountInProgressOrBetter) >= 16) {
        if (TerranHDFastExpand(player)) { return false; }
    }
    
    TerranHDDefaultExtraMidStock(player);
    
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 3, c_TU_Marine );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    
    if (AITechCount(player, c_TB_CommandCenter_Alias, c_techCountCompleteOnly) >= 2) {
        AISetStock( player, 2, c_TB_OrbitalCommand );
    }

    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 5, c_TU_Marine );
    AISetStock( player, 21, c_TU_SCV );
    AISetStock( player, 6, c_TU_Marine );
    AISetStock( player, 2, c_TB_Refinery );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AISetStock( player, 23, c_TU_SCV );
    AISetStock( player, 8, c_TU_Marine );
    AISetStock( player, 25, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 4, c_TB_Refinery );
    AISetStock( player, 27, c_TU_SCV );
    AISetStock( player, 10, c_TU_Marine );
    AISetStock( player, 2, c_TB_Factory );
    AISetStock( player, 29, c_TU_SCV );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_Marine );
    AISetStock( player, 31, c_TU_SCV );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TB_FactoryTechLab );
    AISetStock( player, 33, c_TU_SCV );
    AISetStock( player, 14, c_TU_Marine );
    AISetStock( player, 2, c_TB_FactoryTechLab );
    AISetStock( player, 35, c_TU_SCV );
    AISetStock( player, 7, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TU_SiegeTank );
    AISetStock( player, 37, c_TU_SCV );
    AISetStock( player, 1, c_TB_Armory );
    AISetStock( player, 3, c_TU_SiegeTank );
    AISetStock( player, 41, c_TU_SCV );
    AISetStock( player, 2, c_TB_Armory );
    AISetStock( player, 5, c_TU_SiegeTank );
    AISetStock( player, 43, c_TU_SCV );
    AISetStock( player, 9, c_TB_SupplyDepot );
    AISetStock( player, 45, c_TU_SCV );
    AISetStock( player, 1, c_TR_VehicleWeapons1 );
    AISetStock( player, 47, c_TU_SCV );
    AISetStock( player, 11, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TU_Thor );
    AISetStock( player, 6, c_TU_SiegeTank );
    AISetStock( player, 49, c_TU_SCV );
    AISetStock( player, 1, c_TR_MechPlating1 );
    AISetStock( player, 13, c_TB_SupplyDepot );
    AISetStock( player, 16, c_TU_Marine );
    AISetStock( player, 3, c_TU_Thor );
    AISetStock( player, 51, c_TU_SCV );
    AISetStock( player, 13, c_TB_SupplyDepot );
    AISetStock( player, 3, c_TB_Barracks );
    AISetStock( player, 5, c_TU_Thor );
    AISetStock( player, 53, c_TU_SCV );
    
    AIEnableStock(player);

    //---------------------------------------------------------
    
    AISetAttackStatus(player, c_TU_Marine, 4, 999, c_continuousMerge);
    if (AITechCount(player, c_TU_SiegeTank, c_techCountCompleteOnly) >= 4) {
        AISetAttackStatus(player, c_TU_Thor, 1, 3, c_continuousMerge);
    }

    if (AIGetTime() < 720) {
        if (AITechCount(player, c_TU_Thor, c_techCountInProgressOrBetter) < 5) {
            return false;
        }
    }

    return true;  // Transition to LateGame
}

//--------------------------------------------------------------------------------------------------
//  TerranMidMacroBioHdVH
//--------------------------------------------------------------------------------------------------
bool TerranMidMacroBioHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 16, c_TU_SCV );
    
    TerranBasicDefenseStock(player);

    if (AITechCount(player, c_TU_SCV, c_techCountInProgressOrBetter) >= 16) {
        if (TerranHDFastExpand(player)) { return false; }
    }
    
    TerranHDDefaultExtraMidStock(player);
    
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 3, c_TU_Marine );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    
    if (AITechCount(player, c_TB_CommandCenter_Alias, c_techCountCompleteOnly) >= 2) {
        AISetStock( player, 2, c_TB_OrbitalCommand );
    }

    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 5, c_TU_Marine );
    AISetStock( player, 21, c_TU_SCV );
    AISetStock( player, 6, c_TU_Marine );
    AISetStock( player, 2, c_TB_Refinery );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AISetStock( player, 23, c_TU_SCV );
    AISetStock( player, 8, c_TU_Marine );
    AISetStock( player, 25, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 10, c_TU_Marine );
    AISetStock( player, 27, c_TU_SCV );
    AISetStock( player, 3, c_TB_Barracks );
    AISetStock( player, 2, c_TB_BarracksTechLab );
    AISetStock( player, 29, c_TU_SCV );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 3, c_TB_Refinery );
    AISetStock( player, 31, c_TU_SCV );
    AISetStock( player, 2, c_TU_Marauder );
    AISetStock( player, 1, c_TB_Starport );
    AISetStock( player, 1, c_TB_FactoryTechLab );
    AISetStock( player, 33, c_TU_SCV );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 4, c_TU_Marauder );
    AISetStock( player, 11, c_TU_Marine );
    AISetStock( player, 35, c_TU_SCV );
    AISetStock( player, 6, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TU_SiegeTank );
    AISetStock( player, 4, c_TB_Refinery );
    AISetStock( player, 14, c_TU_Marine );
    AISetStock( player, 7, c_TB_SupplyDepot );
    AISetStock( player, 37, c_TU_SCV );
    AISetStock( player, 1, c_TU_Medivac );
    AISetStock( player, 8, c_TB_SupplyDepot );
    AISetStock( player, 14, c_TU_Marine );
    AISetStock( player, 39, c_TU_SCV );
    AISetStock( player, 9, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TU_SiegeTank );
    AISetStock( player, 2, c_TU_Medivac );
    AISetStock( player, 41, c_TU_SCV );
    AISetStock( player, 10, c_TB_SupplyDepot );
    AISetStock( player, 17, c_TU_Marine );
    AISetStock( player, 1, c_TR_MarineStimPack );
    AISetStock( player, 43, c_TU_SCV );
    AISetStock( player, 11, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TR_MarineShield );
    AISetStock( player, 20, c_TU_Marine );
    AISetStock( player, 2, c_TB_EngineeringBay );
    AISetStock( player, 45, c_TU_SCV );
    AISetStock( player, 12, c_TB_SupplyDepot );
    AISetStock( player, 3, c_TU_SiegeTank );
    AISetStock( player, 3, c_TU_Medivac );
    AISetStock( player, 47, c_TU_SCV );
    AISetStock( player, 6, c_TU_Marauder );
    AISetStock( player, 13, c_TB_SupplyDepot );
    AISetStock( player, 49, c_TU_SCV );

    AIEnableStock(player);

    //---------------------------------------------------------
    
    if (AIGetTime() < 630) {
        if (AITechCount(player, c_TU_Medivac, c_techCountInProgressOrBetter) < 3) {
            return false;
        }
    }

    return true;  // Transition to LateGame
}

//--------------------------------------------------------------------------------------------------
//  TerranMidMacroMechHdVH
//--------------------------------------------------------------------------------------------------
bool TerranMidMacroMechHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 16, c_TU_SCV );
    
    TerranBasicDefenseStock(player);

    if (AITechCount(player, c_TU_SCV, c_techCountInProgressOrBetter) >= 16) {
        if (TerranHDFastExpand(player)) { return false; }
    }
    
    TerranHDDefaultExtraMidStock(player);
    
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 3, c_TU_Marine );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    
    if (AITechCount(player, c_TB_CommandCenter_Alias, c_techCountCompleteOnly) >= 2) {
        AISetStock( player, 2, c_TB_OrbitalCommand );
    }

    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 5, c_TU_Marine );
    AISetStock( player, 21, c_TU_SCV );
    AISetStock( player, 6, c_TU_Marine );
    AISetStock( player, 2, c_TB_Refinery );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AISetStock( player, 23, c_TU_SCV );
    AISetStock( player, 8, c_TU_Marine );
    AISetStock( player, 25, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 3, c_TB_Refinery );
    AISetStock( player, 27, c_TU_SCV );
    AISetStock( player, 10, c_TU_Marine );
    AISetStock( player, 2, c_TB_Factory );
    AISetStock( player, 29, c_TU_SCV );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_Marine );
    AISetStock( player, 31, c_TU_SCV );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TB_FactoryTechLab );
    AISetStock( player, 14, c_TU_Marine );
    AISetStock( player, 33, c_TU_SCV );
    AISetStock( player, 1, c_TB_FactoryReactor );
    AISetStock( player, 7, c_TB_SupplyDepot );
    AISetStock( player, 4, c_TB_Refinery );
    AISetStock( player, 35, c_TU_SCV );
    AISetStock( player, 1, c_TU_SiegeTank );
    AISetStock( player, 3, c_TB_Factory );
    AISetStock( player, 37, c_TU_SCV );
    AISetStock( player, 8, c_TB_SupplyDepot );
    AISetStock( player, 39, c_TU_SCV );
    AISetStock( player, 2, c_TU_Hellion_Alias );
    AISetStock( player, 2, c_TU_SiegeTank );
    AISetStock( player, 4, c_TB_Factory );
    AISetStock( player, 2, c_TB_Armory );
    AISetStock( player, 41, c_TU_SCV );
    AISetStock( player, 4, c_TU_Hellion_Alias );
    AISetStock( player, 10, c_TB_SupplyDepot );
    AISetStock( player, 43, c_TU_SCV );
    AISetStock( player, 2, c_TB_FactoryTechLab );
    AISetStock( player, 3, c_TU_SiegeTank );
    AISetStock( player, 45, c_TU_SCV );
    AISetStock( player, 6, c_TU_Hellion_Alias );
    AISetStock( player, 5, c_TU_SiegeTank );
    AISetStock( player, 1, c_TR_VehicleWeapons1 );
    AISetStock( player, 1, c_TR_MechPlating1 );
    AISetStock( player, 47, c_TU_SCV );
    AISetStock( player, 7, c_TU_Hellion_Alias );
    AISetStock( player, 12, c_TB_SupplyDepot );
    AISetStock( player, 49, c_TU_SCV );
    AISetStock( player, 6, c_TU_SiegeTank );
    AISetStock( player, 10, c_TU_Hellion_Alias );
    AISetStock( player, 7, c_TU_SiegeTank );
    AISetStock( player, 51, c_TU_SCV );

    AIEnableStock(player);

    //---------------------------------------------------------

    if (AIGetTime() < 660) {
        if (AITechCount(player, c_TU_SiegeTank, c_techCountInProgressOrBetter) < 7) {
            return false;
        }
    }

    return true;  // Transition to LateGame
}

//--------------------------------------------------------------------------------------------------
//  TerranMidMacroThorBCHdVH
//--------------------------------------------------------------------------------------------------
bool TerranMidMacroThorBCHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 16, c_TU_SCV );
    
    TerranBasicDefenseStock(player);

    if (AITechCount(player, c_TU_SCV, c_techCountInProgressOrBetter) >= 16) {
        if (TerranHDFastExpand(player)) { return false; }
    }
    
    TerranHDDefaultExtraMidStock(player);
    
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 3, c_TU_Marine );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    
    if (AITechCount(player, c_TB_CommandCenter_Alias, c_techCountCompleteOnly) >= 2) {
        AISetStock( player, 2, c_TB_OrbitalCommand );
    }

    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 5, c_TU_Marine );
    AISetStock( player, 21, c_TU_SCV );
    AISetStock( player, 6, c_TU_Marine );
    AISetStock( player, 2, c_TB_Refinery );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AISetStock( player, 23, c_TU_SCV );
    AISetStock( player, 8, c_TU_Marine );
    AISetStock( player, 25, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 4, c_TB_Refinery );
    AISetStock( player, 27, c_TU_SCV );
    AISetStock( player, 10, c_TU_Marine );
    AISetStock( player, 2, c_TB_Factory );
    AISetStock( player, 29, c_TU_SCV );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_Marine );
    AISetStock( player, 31, c_TU_SCV );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TB_FactoryTechLab );
    AISetStock( player, 33, c_TU_SCV );
    AISetStock( player, 14, c_TU_Marine );
    AISetStock( player, 2, c_TB_FactoryTechLab );
    AISetStock( player, 35, c_TU_SCV );
    AISetStock( player, 7, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TU_SiegeTank );
    AISetStock( player, 37, c_TU_SCV );
    AISetStock( player, 1, c_TB_Armory );
    AISetStock( player, 3, c_TU_SiegeTank );
    AISetStock( player, 41, c_TU_SCV );
    AISetStock( player, 2, c_TB_Armory );
    AISetStock( player, 5, c_TU_SiegeTank );
    AISetStock( player, 43, c_TU_SCV );
    AISetStock( player, 9, c_TB_SupplyDepot );
    AISetStock( player, 45, c_TU_SCV );
    AISetStock( player, 1, c_TR_VehicleWeapons1 );
    AISetStock( player, 47, c_TU_SCV );
    AISetStock( player, 11, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TU_Thor );
    AISetStock( player, 6, c_TU_SiegeTank );
    AISetStock( player, 49, c_TU_SCV );
    AISetStock( player, 1, c_TR_MechPlating1 );
    AISetStock( player, 13, c_TB_SupplyDepot );
    AISetStock( player, 16, c_TU_Marine );
    AISetStock( player, 3, c_TU_Thor );
    AISetStock( player, 51, c_TU_SCV );
    AISetStock( player, 13, c_TB_SupplyDepot );
    AISetStock( player, 3, c_TB_Barracks );
    AISetStock( player, 53, c_TU_SCV );
    
    AIEnableStock(player);

    //---------------------------------------------------------

    if (AIGetTime() < 660) {
        if (AITechCount(player, c_TU_Thor, c_techCountInProgressOrBetter) < 3) {
            return false;
        }
    }

    return true;  // Transition to LateGame
}

//--------------------------------------------------------------------------------------------------
//  TerranMidAirOneBaseAirHdVH
//--------------------------------------------------------------------------------------------------
bool TerranMidAirOneBaseAirHdVH (int player) {
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 13, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    
    TerranBasicDefenseStock(player);

    AISetStock( player, 15, c_TU_SCV );
    AISetStock( player, 2, c_TB_Refinery );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    AISetStock( player, 2, c_TB_Starport );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 2, c_TU_Viking );
    AISetStock( player, 22, c_TU_SCV );
    AISetStock( player, 4, c_TU_Viking );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 23, c_TU_SCV );
    AISetStock( player, 6, c_TU_Viking );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 25, c_TU_SCV );
    AISetStock( player, 8, c_TU_Viking );
    AISetStock( player, 6, c_TB_SupplyDepot );
    AISetStock( player, 3, c_TU_Marine );
    AISetStock( player, 26, c_TU_SCV );
    AISetStock( player, 10, c_TU_Viking );
    AISetStock( player, 7, c_TB_SupplyDepot );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 28, c_TU_SCV );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AIEnableStock(player);

    //---------------------------------------------------------

    AISetAttackStatus(player, c_TU_Viking_Alias, 2, 6, c_continuousMerge);
    
    if (AIGetTime() < 510) {
        if (AITechCount(player, c_TU_Viking_Alias, c_techCountInProgressOrBetter) < 10) {
            return false;
        }
    }

    return true;  // Transition to LateGame
}

//--------------------------------------------------------------------------------------------------
//  TerranMidAirOneBaseDropHdVH
//--------------------------------------------------------------------------------------------------
bool TerranMidAirOneBaseDropHdVH (int player) {
    AIClearStock(player);

    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 12, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    
    TerranBasicDefenseStock(player);

    AISetStock( player, 13, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 14, c_TU_SCV );
    AISetStock( player, 2, c_TB_Refinery );
    AISetStock( player, 16, c_TU_SCV );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 1, c_TB_BarracksReactor );
    AISetStock( player, 19, c_TU_SCV );
    AISetStock( player, 2, c_TB_Starport );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 2, c_TU_Viking );
    AISetStock( player, 6, c_TU_Marine );
    AISetStock( player, 2, c_TU_Medivac );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 8, c_TU_Marine );
    AISetStock( player, 10, c_TU_Marine );
    AISetStock( player, 3, c_TU_Viking );
    AISetStock( player, 3, c_TU_Medivac );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 14, c_TU_Marine );
    AISetStock( player, 5, c_TU_Viking );
    AISetStock( player, 6, c_TB_SupplyDepot );
    AISetStock( player, 18, c_TU_Marine );
    AISetStock( player, 7, c_TU_Viking );
    AISetStock( player, 8, c_TB_SupplyDepot );
    AISetStock( player, 20, c_TU_Marine );
    AISetStock( player, 9, c_TB_SupplyDepot );
    AISetStock( player, 24, c_TU_Marine );

    TerranHDDefaultExtraMidStock(player);

    AIEnableStock(player);

    //---------------------------------------------------------

    AISetAttackStatus(player, c_TU_Viking_Alias, 2, 7, c_continuousMerge);
    if (AITechCount(player, c_TU_Medivac, c_techCountCompleteOnly) >= 2) {
        AISetAttackStatus(player, c_TU_Marine, 8, 16, c_continuousMerge);
    }
    
    if (AIGetTime() < 600) {
        if (AITechCount(player, c_TU_Viking_Alias, c_techCountCompleteOnly) < 7) {
            return false;
        }
    }

    return true;  // Transition to LateGame
}

//--------------------------------------------------------------------------------------------------
//  TerranMidAirExpansionVikingBansheeHdVH
//--------------------------------------------------------------------------------------------------
bool TerranMidAirExpansionVikingBansheeHdVH (int player) {
    AISetFlag(player, e_flagsDiversion, true);
    
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 15, c_TU_SCV );
    
    TerranBasicDefenseStock(player);

    if (AITechCount(player, c_TU_SCV, c_techCountQueuedOrBetter) >= 15) {
        if (TerranHDFastExpand(player)) { return false; }
    }

    AISetStock( player, 16, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    AISetStock( player, 2, c_TB_Refinery );
    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    
    if (AITechCount(player, c_TB_CommandCenter_Alias, c_techCountCompleteOnly) >= 2) {
        AISetStock( player, 2, c_TB_OrbitalCommand );
    }
    
    AISetStock( player, 22, c_TU_SCV );
    AISetStock( player, 2, c_TB_Starport );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AISetStock( player, 26, c_TU_SCV );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 28, c_TU_SCV );
    AISetStock( player, 4, c_TB_Refinery );
    AISetStock( player, 2, c_TU_Viking );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 32, c_TU_SCV );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TB_StarportTechLab );
    AISetStock( player, 36, c_TU_SCV );
    AISetStock( player, 5, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TU_Banshee );
    AISetStock( player, 1, c_TR_BansheeCloak );
    AISetStock( player, 40, c_TU_SCV );
    AISetStock( player, 7, c_TB_SupplyDepot );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 4, c_TU_Banshee );
    AISetStock( player, 44, c_TU_SCV );
    AISetStock( player, 6, c_TU_Banshee );
    AISetStock( player, 48, c_TU_SCV );
    AISetStock( player, 6, c_TU_Marine );
    AISetStock( player, 9, c_TB_SupplyDepot );

    TerranHDDefaultExtraMidStock(player);

    AIEnableStock(player);

    //---------------------------------------------------------
    
    // attack is done by diversion wave with banshees

    if (AIGetTime() < 510) {
        if (AITechCount(player, c_TU_Banshee, c_techCountInProgressOrBetter) < 6) {
            return false;
        }
    }

    return true;  // Transition to LateGame
}

//--------------------------------------------------------------------------------------------------
//  TerranMidAirExpansionBCHdVH
//--------------------------------------------------------------------------------------------------
bool TerranMidAirExpansionBCHdVH (int player) {
    AISetFlag(player, e_flagsDiversion, true);
    
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 15, c_TU_SCV );
    
    TerranBasicDefenseStock(player);

    if (AITechCount(player, c_TU_SCV, c_techCountQueuedOrBetter) >= 15) {
        if (TerranHDFastExpand(player)) { return false; }
    }

    AISetStock( player, 16, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    AISetStock( player, 2, c_TB_Refinery );
    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    
    if (AITechCount(player, c_TB_CommandCenter_Alias, c_techCountCompleteOnly) >= 2) {
        AISetStock( player, 2, c_TB_OrbitalCommand );
    }
    
    AISetStock( player, 22, c_TU_SCV );
    AISetStock( player, 2, c_TB_Starport );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AISetStock( player, 26, c_TU_SCV );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 28, c_TU_SCV );
    AISetStock( player, 4, c_TB_Refinery );
    AISetStock( player, 2, c_TU_Viking );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 32, c_TU_SCV );
    AISetStock( player, 1, c_TB_FusionCore );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 34, c_TU_SCV );
    AISetStock( player, 2, c_TB_StarportTechLab );
    AISetStock( player, 38, c_TU_SCV );
    AISetStock( player, 6, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TU_Battlecruiser );
    AISetStock( player, 42, c_TU_SCV );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 8, c_TB_SupplyDepot );
    AISetStock( player, 46, c_TU_SCV );
    AISetStock( player, 1, c_TR_BattlecruiserYamato );
    AISetStock( player, 50, c_TU_SCV );

    TerranHDDefaultExtraMidStock(player);

    AIEnableStock(player);

    //---------------------------------------------------------
    
    AISetAttackStatus(player, c_TU_Battlecruiser, 1, 2, c_continuousMerge);
    if (AIGetTime() < 600) {
        if (AITechCount(player, c_TU_Battlecruiser, c_techCountCompleteOnly) < 2) {
            return false;
        }
    }

    return true;  // Transition to LateGame
}

//--------------------------------------------------------------------------------------------------
//  TerranMidAirExpansionDropAirHdVH
//--------------------------------------------------------------------------------------------------
bool TerranMidAirExpansionDropAirHdVH (int player) {
    AISetFlag(player, e_flagsDiversion, true);
    
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 15, c_TU_SCV );
    
    TerranBasicDefenseStock(player);

    if (AITechCount(player, c_TU_SCV, c_techCountQueuedOrBetter) >= 15) {
        if (TerranHDFastExpand(player)) { return false; }
    }

    AISetStock( player, 16, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    AISetStock( player, 2, c_TB_Refinery );
    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    
    if (AITechCount(player, c_TB_CommandCenter_Alias, c_techCountCompleteOnly) >= 2) {
        AISetStock( player, 2, c_TB_OrbitalCommand );
    }
    
    AISetStock( player, 22, c_TU_SCV );
    AISetStock( player, 2, c_TB_Starport );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AISetStock( player, 26, c_TU_SCV );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 28, c_TU_SCV );
    AISetStock( player, 4, c_TB_Refinery );
    AISetStock( player, 2, c_TU_Viking );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 32, c_TU_SCV );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TU_Medivac );
    AISetStock( player, 3, c_TU_Marine );
    AISetStock( player, 34, c_TU_SCV );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 6, c_TB_SupplyDepot );
    AISetStock( player, 38, c_TU_SCV );
    AISetStock( player, 4, c_TU_Medivac );
    AISetStock( player, 3, c_TB_Starport );
    AISetStock( player, 3, c_TB_Barracks );
    AISetStock( player, 2, c_TB_BarracksTechLab );
    AISetStock( player, 42, c_TU_SCV );
    AISetStock( player, 7, c_TB_SupplyDepot );
    AISetStock( player, 6, c_TU_Marine );
    AISetStock( player, 5, c_TU_Viking );
    AISetStock( player, 1, c_TR_MarineShield );
    AISetStock( player, 1, c_TR_MarineStimPack );
    AISetStock( player, 46, c_TU_SCV );
    AISetStock( player, 2, c_TU_Marauder );
    AISetStock( player, 7, c_TU_Marine );
    AISetStock( player, 9, c_TB_SupplyDepot );
    AISetStock( player, 6, c_TU_Medivac );
    AISetStock( player, 6, c_TU_Viking );
    AISetStock( player, 8, c_TU_Marine );
    AISetStock( player, 4, c_TU_Marauder );
    AISetStock( player, 8, c_TU_Viking );
    AISetStock( player, 11, c_TB_SupplyDepot );
    AISetStock( player, 50, c_TU_SCV );

    TerranHDDefaultExtraMidStock(player);

    AIEnableStock(player);

    //---------------------------------------------------------

    if (AITechCount(player, c_TU_Medivac, c_techCountCompleteOnly) >= 4) {
        AISetAttackStatus(player, c_TU_Marine, 2, 8, c_continuousMerge);
        AISetAttackStatus(player, c_TU_Marauder, 2, 4, c_continuousMerge);
    }
    
    if (AIGetTime() < 630) {
        if (AITechCount(player, c_TU_Viking_Alias, c_techCountInProgressOrBetter) < 8) {
            return false;
        }
    }

    return true;  // Transition to LateGame
}

//--------------------------------------------------------------------------------------------------
//  TerranMidAirMacroHdVH
//--------------------------------------------------------------------------------------------------
bool TerranMidAirMacroHdVH (int player) {
    AISetFlag(player, e_flagsDiversion, true);
    
    AIClearStock(player);
    
    AISetStock( player, 1, c_TB_CommandCenter_Alias );
    AISetStock( player, 10, c_TU_SCV );
    AISetStock( player, 1, c_TB_SupplyDepot );
    AISetStock( player, 15, c_TU_SCV );
    
    TerranBasicDefenseStock(player);

    if (AITechCount(player, c_TU_SCV, c_techCountQueuedOrBetter) >= 15) {
        if (TerranHDFastExpand(player)) { return false; }
    }

    AISetStock( player, 16, c_TU_SCV );
    AISetStock( player, 1, c_TB_Refinery );
    AISetStock( player, 17, c_TU_SCV );
    AISetStock( player, 1, c_TB_Barracks );
    AISetStock( player, 18, c_TU_SCV );
    AISetStock( player, 2, c_TB_SupplyDepot );
    AISetStock( player, 19, c_TU_SCV );
    AISetStock( player, 2, c_TB_Refinery );
    AISetStock( player, 20, c_TU_SCV );
    AISetStock( player, 1, c_TB_Factory );
    AISetStock( player, 1, c_TB_OrbitalCommand );
    
    if (AITechCount(player, c_TB_CommandCenter_Alias, c_techCountCompleteOnly) >= 2) {
        AISetStock( player, 2, c_TB_OrbitalCommand );
    }
    
    AISetStock( player, 22, c_TU_SCV );
    AISetStock( player, 2, c_TB_Starport );
    
    TerranHDEmergencyDetectionAntiAir(player);

    AISetStock( player, 26, c_TU_SCV );
    AISetStock( player, 3, c_TB_SupplyDepot );
    AISetStock( player, 1, c_TU_Marine );
    AISetStock( player, 28, c_TU_SCV );
    AISetStock( player, 4, c_TB_Refinery );
    AISetStock( player, 2, c_TU_Viking );
    AISetStock( player, 2, c_TU_Marine );
    AISetStock( player, 32, c_TU_SCV );
    AISetStock( player, 1, c_TB_FusionCore );
    AISetStock( player, 4, c_TB_SupplyDepot );
    AISetStock( player, 34, c_TU_SCV );
    AISetStock( player, 2, c_TB_StarportTechLab );
    AISetStock( player, 38, c_TU_SCV );
    AISetStock( player, 6, c_TB_SupplyDepot );
    AISetStock( player, 2, c_TU_Battlecruiser );
    AISetStock( player, 42, c_TU_SCV );
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 4, c_TU_Marine );
    AISetStock( player, 8, c_TB_SupplyDepot );
    AISetStock( player, 46, c_TU_SCV );
    AISetStock( player, 1, c_TR_BattlecruiserYamato );
    AISetStock( player, 50, c_TU_SCV );

    TerranHDDefaultExtraMidStock(player);

    AIEnableStock(player);

    //---------------------------------------------------------

    if (AIGetTime() < 570) {
        if (AITechCount(player, c_TR_BattlecruiserYamato, c_techCountInProgressOrBetter) < 2) {
            return false;
        }
    }

    return true;  // Transition to LateGame
}

//==================================================================================================
//  LATE GAME
//==================================================================================================

// Late Game is very similar to VyHd, but with delayed expanding and upgrading to make it weaker

//--------------------------------------------------------------------------------------------------
//  TerranLateHdVH
//--------------------------------------------------------------------------------------------------
void TerranLateHdVH (int player) {
    int armyCompareEstimate = AIArmyComparisonEstimate(player);
    int foodUsed = PlayerGetPropertyInt(player, c_playerPropSuppliesUsed);

    // only allow scouting if I have plenty of workers
    AIScoutingEnable(player, 16, c_TU_SCV);
    // calculate a limit on how much simultaneous teching can happen
    AISetTechLimitLevels(player);


// ****************** Start Restock ****************** //
    AIClearStock(player);

// Very basic recovery start
    TerranHDRecoveryStart(player);

// Very basic farms & peons
    AISetStockFarms( player, c_TB_SupplyDepot, c_stockNormalFarms);
    AISetStockPeons( player, 16, c_TU_SCV, c_stockMinPeons, c_stockAlways);

// Desperate expand (we're about to run out of minerals/gas)
    AIDefaultExpansion(player, c_TB_CommandCenter, 3000, 1000, c_expandVitalHard);

// Choose what type of endgame army we'd like to make
    UpdateHDTerranLateGameArmy(player);

// Bare minimum army
    if (foodUsed < 180) {
        TerranHDLateGameArmy(player, e_armyTypeMinimum);
    }

// Basic peons
    AISetStockPeons( player, 24, c_TU_SCV, c_stockMinPeons, c_stockAlways);

// Urgent early detection
    if (AINeedsDetection(player)) {
        AISetStock( player, 1, c_TU_Raven );
        AISetStock( player, 1, c_TB_OrbitalCommand );
    }

// Barely adequete army including anti-air
    if (foodUsed < 180) {
        TerranHDLateGameArmy(player, e_armyTypeBase);
    }
    
// Basic towns, farms, & peons
    AIDefaultEconomy(player, c_TB_CommandCenter_Alias, c_TB_Refinery, c_TB_SupplyDepot, c_TU_SCV, 70, c_stockAlways);

// Low expand (we're running low on minerals/gas)
    AIAdjustedDefaultExpansion(player, c_TB_CommandCenter, 6000, 2000, c_expandVitalHard, armyCompareEstimate);

// Minimum normal detection
    if (AISuspectDetectionDanger(player, c_lateDetectionDangerTime)) {
        AISetStock( player, 1, c_TB_OrbitalCommand );
    }

// On an air map build at least one transport as long as we have some other units/army
    if (AIGetUserInt(player, c_numGroundStartLocs) == 0) {
        AISetStock( player, 1, c_TU_Medivac );
    }

// Nearly food capped units
    if (foodUsed > 160) {
        AISetStock( player, 2, c_TU_Raven );
        AISetStock( player, 2, c_TU_Medivac );
        if (AIWantsMultipleTransport(player)) {
            AISetStock( player, 5, c_TU_Medivac );
        }

        if (foodUsed >= 180) {
            TerranHDLateGameArmy(player, e_armyTypeMinimum);
            TerranHDLateGameArmy(player, e_armyTypeBase);
        }
    }

// Basic small army
    TerranHDLateGameArmy(player, e_armyTypeSmall);

// Basic production buildings
    AISetStock( player, 2, c_TB_Barracks );
    AISetStock( player, 1, c_TB_BarracksTechLab );
    
// Normal expand
    AIAdjustedDefaultExpansion(player, c_TB_CommandCenter, 10000, 4000, c_expandNormalHard, armyCompareEstimate);
    
// Make Counter Units
    TerranHDMakeCounters(player);

// Medium sized army
    TerranHDLateGameArmy(player, e_armyTypeMedium);

// Vital upgrades
    TerranHDVitalUpgrades(player);
    
// Other towns defense
    TerranHDDefenseOtherTowns(player);

// Large sized army
    TerranHDLateGameArmy(player, e_armyTypeLarge);

// General upgrades
    TerranHDGeneralUpgrades(player);

// Main base defense
    TerranHDDefenseMainTown(player);

// Terran harrassment
    TerranHDHarass(player);

// Multiple detectors & scouts & a transport
    AISetStockUnitNext( player, 1, c_TU_Medivac, c_stockAlways );
    AISetStockUnitNext( player, 2, c_TU_Raven, c_stockAlways );

// Middle expand
    AIAdjustedDefaultExpansion(player, c_TB_CommandCenter, 15000, 6000, c_expandNormalHard, armyCompareEstimate);

// Extra detection & scouts & transports
    AISetStockUnitNext( player, 3, c_TU_Medivac, c_stockAlways );
    
// Late expand
    AIAdjustedDefaultExpansion(player, c_TB_CommandCenter, 20000, 8000, c_expandNormalHard, armyCompareEstimate);
  
// Extra production buildings
    AISetStockUnitNext( player, 4, c_TB_Barracks,           c_stockIdle );
    AISetStockUnitNext( player, 1, c_TB_BarracksTechLab,    c_stockIdle );
    AISetStockUnitNext( player, 1, c_TB_BarracksReactor,    c_stockIdle );
    AISetStockUnitNext( player, 2, c_TB_Factory,            c_stockIdle );
    AISetStockUnitNext( player, 2, c_TB_Starport,           c_stockIdle );
    AISetStockUnitNext( player, 2, c_TB_FactoryTechLab,     c_stockIdle );
    AISetStockUnitNext( player, 1, c_TB_StarportTechLab,    c_stockIdle );
    AISetStockUnitNext( player, 2, c_TB_BarracksTechLab,    c_stockIdle );

// Extra research buildings
    if (AIHasRes(player,700,500)) {
        AISetStockUnitNext( player, 2, c_TB_EngineeringBay, c_stockAlways );
        AISetStockUnitNext( player, 2, c_TB_Armory, c_stockAlways );
    }

// Minor upgrades
    TerranHDMinorUpgrades(player);

// Idle expand (very low priority, to prevent us from sitting around with idle peons)
    AIAdjustedDefaultExpansion(player, c_TB_CommandCenter, 30000, 10000, c_expandIdleHard, armyCompareEstimate);

// Entire Army
    TerranHDLateGameArmy(player, e_armyTypeFull);

    AIEnableStock(player);    
// ****************** End Restock ****************** //

}
