So I have an AI and I want it to build 3 Probes, then build a Pylon, 2 Gateways, before continuing to make 4 Probes. I want to force the AI to do this build and follow the order that I had specified. What this means is that the AI should not build anything in between the first 3 Probes and the Pylon, the Pylon and the 2 Gateways, etc.
How do I achieve this? I've tried using the Set Stock action like this:
But the AI doesn't build any probes. I've also tried using the Train and Build actions:
AIAdvanced-Train3unitsoftypeProbeinplayer2's town 0 with priority 0AIAdvanced-Build1unitsoftypePyloninplayer2's town 0 with priority 0 using build flags -1AIAdvanced-Build2unitsoftypeGatewayinplayer2's town 0 with priority 0 using build flags -1AIAdvanced-Train4unitsoftypeProbeinplayer2's town 0 with priority 0
But with this, the order is messed up.
How do I ensure that the AI strictly follows the build including its order?
Make sure you initialize the AI correctly. Get rid of the "start melee AI" trigger that comes by default when you create a new map.
What I do to initialize the AI is run these triggers in this order:
Initialize campaign mode, clear the stock lists, clear all build requests, initialize campaign towns, initialize campaign harvesting and thenenable restocking.
Each of those is a trigger that you should be able to find by typing it into the search bar and filling out details about which player you are applying this to.
AFTER YOU HAVE INITIALIZED:
set stock to make 9 probes. At the moment you are setting the stock to 3 probes, what then happens is that the computer is checking that it has three probes (it starts with 6 so this is already satisfied and can check that off the list) and decides it doesn't need to make any more.
AFAIK there is no way you can tell the AI what order to build things in. You will have to give it orders for when you want things to happen. For instance a simple way you could do this is by running a trigger with wait loops like this:
//this covers the initial 6 probessetstocktomake6probes// build probessetstocktomake3probeswait40seconds//pylonsetstocktomake1pylonwait40seconds//gatewayssetstocktomake2gatewayswait20seconds//more probessetstocktomake2probes
Or you could start to get more complex such as having an array of unit types such as this which will constantly check if it can afford the next step and do so when available.
intstep=0;//account for initial workerssetstocktomake6ofprobes;//build orderarray=[probe,probe,probe,pylon,gateway,gateway,probe,probe];while(i<=7){if(player2minerals>=unitcostofarray[i]){setstocktomake1ofarray[i];i=i+1;}wait0.2seconds;}
Or you could get even more complex...
But the point is you have to tell the AI when to build it as well as what to build.
The set stock action queues a build request for the AI to fulfil. They will be fulfilled in the order you call them. The advanced Melee AI for example will call 20 or more set stock actions at any given time giving an entire build sequence for that point of the game.
It is important to note the AI might eventually discard current stock orders. As such the correct approach (used by melee AI) is to periodically clear stock orders and re-issue them appropriately for the current state of the game in the order you want them fulfilled.
For example calling...
Player two will make sure to have 3 probes, building as required.
AI Advanced - Set stock for player 2 to make 3 units of type Probe
Player two will make sure to 1 pylon, building as required.
AI Advanced - Set stock for player 2 to make 1 units of type Pylon
Player two will make sure to 2 Gateway, building as required.
AI Advanced - Set stock for player 2 to make 2 units of type Gateway
Player two will make sure to 4 Probes, building as required (which should logically be +1 from above).
AI Advanced - Set stock for player 2 to make 4 units of type Probe
Do note that for any AI to work the owner (Player 2 in this case) must be an active computer controller. Open or human slots will not work as they cannot have AI running.
Also note that starting as campaign AI does not a main strategic loop. This means all build sequences you will need to provide. Another way is to use custom imported Melee AI scripts which replace the default melee AI scripts. These allow you to register your own strategic functions where you can declare your own build order. AI scripts are defined on a race by race basis and it is unclear if they simply use Race data entry name or if they are hard-coded by the SC2 engine.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
So I have an AI and I want it to build 3 Probes, then build a Pylon, 2 Gateways, before continuing to make 4 Probes. I want to force the AI to do this build and follow the order that I had specified. What this means is that the AI should not build anything in between the first 3 Probes and the Pylon, the Pylon and the 2 Gateways, etc.
How do I achieve this? I've tried using the Set Stock action like this:
But the AI doesn't build any probes. I've also tried using the Train and Build actions:
But with this, the order is messed up.
How do I ensure that the AI strictly follows the build including its order?
Has anyone found a working solution?
Unfontunately, I suck at working with the AI, probably renee or finite turtles would be the best people to ask.
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
Make sure you initialize the AI correctly. Get rid of the "start melee AI" trigger that comes by default when you create a new map.
What I do to initialize the AI is run these triggers in this order:
Initialize campaign mode, clear the stock lists, clear all build requests, initialize campaign towns, initialize campaign harvesting and thenenable restocking.
Each of those is a trigger that you should be able to find by typing it into the search bar and filling out details about which player you are applying this to.
AFTER YOU HAVE INITIALIZED:
set stock to make 9 probes. At the moment you are setting the stock to 3 probes, what then happens is that the computer is checking that it has three probes (it starts with 6 so this is already satisfied and can check that off the list) and decides it doesn't need to make any more.
AFAIK there is no way you can tell the AI what order to build things in. You will have to give it orders for when you want things to happen. For instance a simple way you could do this is by running a trigger with wait loops like this:
Or you could start to get more complex such as having an array of unit types such as this which will constantly check if it can afford the next step and do so when available.
Or you could get even more complex...
But the point is you have to tell the AI when to build it as well as what to build.
The set stock action queues a build request for the AI to fulfil. They will be fulfilled in the order you call them. The advanced Melee AI for example will call 20 or more set stock actions at any given time giving an entire build sequence for that point of the game.
It is important to note the AI might eventually discard current stock orders. As such the correct approach (used by melee AI) is to periodically clear stock orders and re-issue them appropriately for the current state of the game in the order you want them fulfilled.
For example calling...
Do note that for any AI to work the owner (Player 2 in this case) must be an active computer controller. Open or human slots will not work as they cannot have AI running.
Also note that starting as campaign AI does not a main strategic loop. This means all build sequences you will need to provide. Another way is to use custom imported Melee AI scripts which replace the default melee AI scripts. These allow you to register your own strategic functions where you can declare your own build order. AI scripts are defined on a race by race basis and it is unclear if they simply use Race data entry name or if they are hard-coded by the SC2 engine.