SC2Mapster.com Wiki

SC2 API / Functions / AIDefaultEconomy

AIDefaultEconomy

native void AIDefaultEconomy (int player, string hall, string gas, string food, string peon, int cap, bool peonMode);

Automatically control the basic production of workers and vespene gas harvesting structures.

Parameters

int player

Player number

string hall

Town Hall type to produce. Can be one of

c_TB_CommandCenter_Alias     = "Alias_CommandCenter";
c_PB_Nexus                   = "Nexus";
c_ZB_Hatchery_Alias          = "Alias_Hatchery";
string gas

Gas building type to produce. Can be one of

c_TB_Refinery                = "Refinery";
c_PB_Assimilator             = "Assimilator";
c_ZB_Extractor               = "Extractor";
string food

Food building type to produce. Can be one of

c_TB_SupplyDepot             = "SupplyDepot";
c_PB_Pylon                   = "Pylon";
c_ZU_Overlord                = "Overlord";
string peon

Peon type to produce. Can be one of

c_TU_SCV                     = "SCV";
c_PU_Probe                   = "Probe";
c_ZU_Drone                   = "Drone";
int cap

Maximum number of peon

bool PeonMode

Build peon when idle or as quickly as possible. Values can be

  • c_stockIdle
  • c_stockAlways

Examples

Example #1: Protoss Build
static void LateGnd (int player) {
    AIClearStock(player);

    AIDefaultEconomy(player, c_PB_Nexus, c_PB_Assimilator, c_PB_Pylon,
                     c_PU_Probe, 8, c_stockAlways);
    AIDefaultExpansion(player, c_PB_Nexus, 6000, 0, c_expandDefault);
   // ...
}
Example #2: Terran Build
static void TerranMidGndA (int player) {
    AIClearStock(player);

    AIDefaultEconomy(player, c_TB_CommandCenter_Alias, c_TB_Refinery,
                     c_TB_SupplyDepot, c_TU_SCV, 8, c_stockAlways);

    if (AISawCloakedUnit(player)) {
        AISetStock( player, 2, c_TB_MissileTurret );
        AISetStock( player, 1, c_TB_OrbitalCommand );
    }
    // ...
}
Example #3: Zerg Build
static void ZergMidAirB (int player) {
    AIClearStock(player);

    AIDefaultEconomy(player, c_ZB_Hatchery_Alias, c_ZB_Extractor, 
                     c_ZU_Overlord, c_ZU_Drone, 8, c_stockIdle);
    AIDefaultExpansion(player, c_ZB_Hatchery_Alias, 6000, 1000, c_expandDefault);

    AISetStock( player, 1, c_ZU_Queen );
    AISetStock( player, 2, c_ZU_Mutalisk );
    AISetStock( player, 2, c_ZU_Hydralisk );
    // ...
}

Notes

  • Allowing this function to run the AI's initial economy results in undesirable supply management. New supply units are built too early. Testing with Zerg showed a new Overlord being built as soon as there were less than 8 supply available. This results in Overlords being built immediately upon map initialization, again at 11/18 drones, and again at 19/26 drones.
  • The AI will not build the maximum number of peons unless there are enough mineral piles to justify them. It appears to stop at 21 peons (not the max useful number of 24) for a starting location with 8 mineral piles, plus another 6 if two gas sites are being harvested. Once an expansion is built more peons will be produced.
  • The number of peons specified appears to have an impact on how soon the AI expands via AIDefaultExpansion() when the mineral and gas parameters of that function are set to 0. More peons means that the AI will not let it's pile of minerals get as low before deciding to expand. At 21 peons harvesting minerals, the AI seems to expand at around 2800-3000 minerals remaining on the ground. At 10 peons mining the AI allows the mineral piles to be completely depleted before expanding.
  • Using c_stockIdle for Zerg results in Drones being built one at a time even if larva and minerals are available.
  • You can make the AI not build a vespene harvesting structure, not harvest gas, and not build the 6 additional peons by specifying the wrong kind of gas mining structure. The code below is an example of this using a Protoss Assimilator in an AIDefaultEconomy() call for a Zerg AI.
AIDefaultEconomy(player, c_ZB_Hatchery_Alias, c_PB_Assimilator,  c_ZU_Overlord, c_ZU_Drone, 33, c_stockIdle);

You must login to post a comment. Don't have an account? Register to get one!

Table of contents

  1. 1 Notes

Facts

Date created
Mar 05, 2010
Last updated
Mar 13, 2010

Authors