Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - hd

#46
AI Development / Re: Idea for AI unit detection...
March 06, 2010, 01:04:08 PM
Quote from: Kernel64 on March 06, 2010, 09:45:43 AMWhat I also don't know how is getting the AI to determine the human player's int value.

int hdGetOpponent (int player) {
    unitgroup enemyGroup;
    int enemyPlayer = -1;
    enemyGroup = UnitGroupAlliance(player, c_unitAllianceEnemy, null, null, c_noMaxCount);
    enemyPlayer = AIGetPlayerGroup(enemyGroup);
   
    return enemyPlayer;
}


I haven't tested it for more than 2 players, but it works flawlessly 1v1.
#47
AI Development / Re: Idea for AI unit detection...
March 06, 2010, 12:57:07 PM
Okay, so I took a different approach just to see if I could get the AI's units (not the enemies).

After some tinkering, I created a function that returns a unitgroup that consists of all of the AI's forces.

Now, this would be used only once to get the starting units (buildings included) for the AI. Then you could create a recursive function to check each unit and add any additional AI forces to the check list and then check to see if any of the AI's units see anything.

unitgroup zergGetAllUnits(int player) {
    unitgroup pUnits = null;
    int unitCount;
    unit pUnit;
    string unitType;
    int droneCount;
    unit startUnit;
   
    startUnit = AIGrabUnit(player, c_ZU_Drone, c_prioNone, null);
   
    pUnits = AIFindUnits(player, null, UnitGetPosition(startUnit), 1000, c_noMaxCount);
    unitCount = UnitGroupCount(pUnits, c_unitCountAll);
    droneCount = 0;
   
    TriggerDebugOutput(1, StringToText("Unit count for Player " + IntToString(player) + ": " + IntToString(unitCount)), true);
   
    while (unitCount > 0) {
        pUnit = UnitGroupUnit(pUnits, unitCount);
        unitType = UnitGetType(pUnit);
         
        if (unitType == c_ZU_Drone) {
             droneCount = droneCount + 1;
        }
       
        unitCount = unitCount - 1;
    }
   
    TriggerDebugOutput(1, StringToText(IntToString(droneCount) + " drones"), true);
   
    return pUnits;
}


One thing I've learned from this is you cannot use a null point for AIFindUnits because it will return 0. I also found that there is a maximum range you can use (1 million crashed the game). If you specify null on the unittype, it will return all units found, period.

The difficult part is getting a unit to start with (hence AIGrabUnit). AIGrabUnit allows you to specify a null point (grabbing the first one of the specified type it finds). However, I don't think you can specify a null unittype for AIGrabUnit because then it won't know what to grab... on the contrary, it could just grab the first unit it finds period.

Now, if we think back to the wave think function, I believe all units end up in a wave from the very beginning of a game. If that's true, we can just cycle through each wave, grabbing each unit until eventually, we find something.
#48
AI Development / Re: Idea for AI unit detection...
March 05, 2010, 09:01:53 PM
I'm a few steps closer to being able to test this...

I need to know how to get the sight radius of a unit. I was thinking it would have something to do with UnitGetPropertyInt but I don't know what flag to use to get it.

void AIWaveThinkZerg (int player, wave w, int type) {
    // hd: seeing if we can pick up opposing unit activity
    unitgroup found;
    unitgroup enemyGroup;
    unitgroup waveGroup = AIWaveGetUnits(w);
    int enemyCount;
    aifilter filter;
   
    AIWaveThinkDefault(player, w, type);
   
    for (int i = 0; i < UnitGroupCount(waveGroup); i++) {
        found = AIFindUnits(player, null, UnitGetPosition(UnitGroupUnit(waveGroup, i)), [sight range of unit here], c_noMaxCount);
        // filter = AIFilter(player);
        //AISetFilterAlliance(filter, c_playerGroupEnemy);
        enemyGroup = UnitGroupFilterThreat(found, [wave unit], null, 0);
        enemyCount = UnitGroupCount(enemyGroup, c_unitCountAlive);
       
        if (enemyCount <= 0) { return; }
        else {
            // found something, add found enemy unit/building to an array of enemy units
            // set a priority system based off count of enemy units found / type of units
        }
    }
}
#49
AI Development / Idea for AI unit detection...
March 05, 2010, 08:20:17 PM
So, I'm trying to make my AI identify enemy units/buildings when they become visible to my AI's units/buildings.

I'm thinking of adding it to the wave think

void AIWaveThinkZerg (int player, wave w, int type) {
    // hd: seeing if we can pick up opposing unit activity
    unitgroup found;
    unitgroup enemyGroup;
    int enemyCount;
    aifilter filter;
   
    AIWaveThinkDefault(player, w, type);
   
    for (int i = 0; i < AIWaveUnitCount(w); i++) {
        found = AIFindUnits(player, null, UnitGetPosition([cycle through wave units here]), [sight range of unit here], c_noMaxCount);
        // filter = AIFilter(player);
        //AISetFilterAlliance(filter, c_playerGroupEnemy);
        enemyGroup = UnitGroupFilterThreat(found, [wave unit], null, 0);
        enemyCount = UnitGroupCount(enemyGroup, c_unitCountAlive);
       
        if (enemyCount <= 0) { return; }
        else {
            // found something, add found enemy unit/building to an array of enemy units
            // set a priority system based off count of enemy units found / type of units
        }
    }
}


Now, obviously the above code won't work as is. I don't know how to cycle through each unit in a wave or to obtain the field of vision of a unit... but if we could get this solved, it would be really easy to make the AI very human like, make scouting mean something and setup reactive game play from the AI
#50
AI Development / Variable Arrays...
March 05, 2010, 03:46:41 PM
Anyone have a good grasp of how these function in Galaxy?

I've seen a few references to arrays but I'm not sure how to declare them, if you have to explicitly declare the size or if it's dynamic and why they're dotting the ends.

For example: "AreaArray[0].Radius";

Is the . refering to a sub variable of AreaArray[0] or is it calling a function to be run on the value of AreaArray[0]? If it's calling a function, is it array specific?
#51
AI Development / Re: Help With Functions
March 05, 2010, 03:33:52 PM
Quote from: SPmac on March 05, 2010, 11:37:02 AM
The theory of this works as I need it to, but that's not exactly what I'm after..

if(AITechCount(player, c_PU_Probe, c_techCountCompleteOnly) <{

AISetStock(player, 10, c_PU_Probe);

}


if(AITechCount(player, c_PU_Probe, c_techCountCompleteOnly) >={

AISetStock(player, 1, c_PB_Pylon);

AISetStock(player, 1, c_PB_Assimilator);

AISetGasPeonCountOverride(player, c_townMain, 3);

}


if(AITechCount(player, c_PU_Probe, c_techCountCompleteOnly) >= 8

&& AITechCount(player, c_PB_Pylon, c_techCountCompleteOnly) >= 1

&& AITechCount(player, c_PB_Assimilator, c_techCountCompleteOnly) >= 1){

AISetStock(player, 1, c_PB_Gateway);

AISetStock(player, 2, c_PB_Pylon);

AISetStock(player, 11, c_PU_Probe);

}


What I'm trying to do is execute these commands, and more like these, in my own functions, (Not using [race]0 files) in order to create a non-linear or non-timebased AI. My problem right now is figuring out the correct point to start calling these functions. The last set of functions int the OP up there is where the problem lies... Where I am calling them from or how I'm calling them must be illegal, because nothing loads on startup.

but TVM for your effort;)

The reason you load the game and nothing comes up once on the map is because your IF-THEN-ELSE statements are in error.

if(AITechCount(player, c_PU_Probe, c_techCountCompleteOnly) <{

Less than what?

if(AITechCount(player, c_PU_Probe, c_techCountCompleteOnly) >={

Greater than or equal to what?

#52
my ai already takes opponents race into account, though i wasn't aware of PlayerRace(int player) and as a result built bloated and convoluted functions to find the enemy race ;\
#53
AI Development / Re: AI Editing and Information
March 03, 2010, 04:20:01 PM
Quote from: itsarabbit on March 03, 2010, 02:59:34 PM
http://darkblizz.org/Forum2/ai-development/ai-script-editing-tool/
It will feature a debug mode.

i'm quite curious how he's going to put in debugging without a complete list of available functions, constants, variables, etc. and executing the code without the information, you won't know if a variable is returning null, or incorrectly, if a function is failing, where it's getting hung up, if there's bottlenecking in ai orders/builds/etc.
#54
AI Development / Re: AI Editing and Information
March 03, 2010, 02:39:59 PM
Is there any way to turn on a sort of debug mode that will spit out errors in the ai code? would make it a hell of a lot easier to track things down  ::)
#55
AI Development / Re: Could use some help...
March 03, 2010, 07:36:36 AM
Quote from: Kernel64 on March 03, 2010, 07:09:18 AM
have you tried techcount?

Actually, was just about to update the thread saying that AITechCount returns an integer of the amount of the passed unit type.

AITechCount(int player, unit type, int flag)

The only flags that seem to be available are c_techCountInProgressOrBetter and c_techCountCompleteOnly where InProgressOrBetter counts those currently being built + those finished being built and CompleteOnly will only count those built but not in progress.
#56
AI Development / Could use some help...
March 03, 2010, 06:44:16 AM
Update: found aitechcount

So, I've been working on an AI and as of right now, I have it able to beat the 5.5 AI before late game kicks in.

But, unfortunately I can't seem to find information I need to make it more advanced.

If anyone can find a function for unit counting for the AI (especially counting a specific type) that'd be great. It would probably look something like AIGetUnitCount(int player, unit type); where type being left null will count all units. I know there's a function for counting peons (workers [scvs, drones, probes]).

We should probably compile a list of all the AI functions we can find.