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 - 1337

#1
AI Scripts / Re: 1337 AI V0.8 Preview
March 08, 2010, 03:05:45 PM
Shameless bump for preview. Leaving town for a couple days; I will continue working on the AI and post update when I return.
#2
Thank you so much HD that was exactly what I needed. Here's my final version:
//Count players
i = 1;
j = 16;   //this is the max. setting it to 17+ generates an error
TOTAL_PLAYERS = 0;

while(i < j)
{
   if(PlayerRace(i) == "Prot" || PlayerRace(i) == "Terr" || PlayerRace(i) == "Zerg")
   {
      TOTAL_PLAYERS = TOTAL_PLAYERS + 1;
   }
   //TriggerDebugOutput(1, StringToText("Player " + IntToString(i) + " color index: "+IntToString(PlayerGetColorIndex(i, false))), true);
   i = i + 1;
}

TriggerDebugOutput(1, StringToText("TOTAL_PLAYERS: "+IntToString(TOTAL_PLAYERS)), true);

As noted in the comment, I cannot loop higher than i = 15 without generating runtime errors. IDK why.
#3

It just takes an order and a single unit as the target.


order o;
unit u;OrderSetTargetUnit(o,u);
#4
AI Scripts / Re: Star IAI v1.0 (Protoss Only)
March 08, 2010, 05:20:54 AM
I am sad to hear that you won't be continuing this project. It was a great inspiration to me. It has some original ideas that I haven't seen in any other AI so far. I am working to incorporate the best parts from your AI plus some from StarCrack into mine... so it will live on in spirit!


I wish you the best of luck in your real life ;)
#5
Quote from: Aeg1s on March 05, 2010, 05:02:17 PMAlso, all variables have to be declared at the top of the function before anything else.
QFE - you will forget this one so many times.


Variables must be declared like this:

int a;
int b;
point p;
unitgroup g;


p = PlayerStartLocation(player);



This code doesn't work:


int a;
int b;
point p = PlayerStartLocation(player);
unitgroup g;





One more gotcha, don't try to assign the value of functions that return fixed to int variables. For example:
int dist;
dist = DistanceBetweenPoints(UnitGetPosition(u2), UnitGetPosition(u1)); //error
dist = FixedToInt(DistanceBetweenPoints(UnitGetPosition(u2), UnitGetPosition(u1))); //works


You will have to look up the function declarations to see which ones return a fixed...
#6
I want to know how many total players are in the game... Still working hard on the 1337 AI but I really need this (and how to count the number of units in production at a building).


I found these in <SC2>/Mods/Core.SC2Mode/Base.SC2Data/TriggerLibs/GameData/Game.galaxy:


//  EPlayerType
const int c_playerTypeNone = 0;
const int c_playerTypeUser = 1;
const int c_playerTypeComputer = 2;
const int c_playerTypeNeutral = 3;
const int c_playerTypeHostile = 4;
const int c_playerTypeReferee = 5;
const int c_playerTypeSpectator = 6;



But I can't for the life of me find a function to get the enum value given a player number.
#7
To use my code, add it to the beginning of Protoss0. I'm not sure but Galaxy may require that prerequisite functions be declared before functions that use them. Add a "bool weNeedProbes = true;" global variable declaration at the top of the Protoss0 file.


Then somewhere in the ProtossOpenGnd0 and ProtossOpenMidA/B etc calls, add in "ChronoBoost(player, true);" and it ought to work...
#8
Quote from: asdf14 on March 07, 2010, 10:42:42 AM
Again, this is OOP model you are thinking about. Galaxy is not object-oriented and point is not a class, so it doesn't have methods (point.getX()) or properties (point.x).
Now, if you really wanted to, here's an example which may work and uses a struct to hold both the point and its coordinates:
struct myPoint
{
int x;
int y;
point coordinates;
}
void createMyPoint (int x, int y)
{
myPoint.x = x;
myPoint.y = y;
myPoint.coordinates = (x, y);
}



You are burning me for using OOP model but then you use myPoint.x in your call. Did you even test this code to see if it works? Looks too easy to be true.


Although if it does work maybe I could use (x,y) = myPoint.coordinates to get the values out...
#9

Yeah I haven't been able to figure this out. For now my ChronoBoost code prioritizes Nexi based on a global boolean "weNeedProbes" and once that boolean becomes false, then we switch to WarpGates and Gateways. The "weNeedProbes" flag is set in the main AI code once probes exceeds 30*(towns-1) + 24. (all towns have 30 probes except for the newest one which has 24). If the beAggressive flag is false then it always prioritizes Nexi.



Here is my ChronoBoost function (from the soon-to-be-released 1337 AI v0.4):


void ChronoBoost(int player, bool beAggressive)
{
   unitfilter uf1;
   aifilter af1;
   unitgroup g1;
   unitgroup g2;
   unit u1;
   unit u2;
    order o1;
   string firstprio;
   string secondprio;
   string thirdprio;
   int i;
   int j;
   fixed r = AIUnitFixed(player, c_PB_Nexus, c_fieldRadius) + AIAbilityFixed(player, "TimeWarp", c_fieldRange0);
   
   //Setup target filters
   uf1 = UnitFilterStr(AIAbilityStr(player, "TimeWarp", c_fieldTargetFiltersAB));         //only valid Time Warp targets
   UnitFilterSetState(uf1, c_targetFilterUnderConstruction, c_unitFilterExcluded);         //dont attempt to target buildings under construction
   af1 = AIFilter(player);
   AISetFilterBits(af1, uf1);
   AISetFilterBehaviorCount(af1, c_noBehaviorMin, c_noBehaviorMax, "TimeWarpProduction");  //Filter out targets that are already buffed.
   
   g1 = AIFindUnits(player, c_PB_Nexus, PlayerStartLocation(player), 9999, c_noMaxCount);
   j = UnitGroupCount(g1,c_unitCountAlive);
   i = 1;
   while(i <= j)
   {
      u1 = UnitGroupUnit(g1,i);
      if (u1)
      {
         if (UnitGetPropertyInt(u1, c_unitPropEnergy, c_unitPropCurrent) >= 25)
         {
            o1 = AICreateOrder(player, "TimeWarp", 0);
           
            if(!weNeedProbes && beAggressive)   //only prioritize gateways if we don't need probes
            {
               firstprio = c_PB_Gateway;
               secondprio = c_PB_WarpGate;
               thirdprio = c_PB_Nexus;
            }
            else                        //always prioritize nexi if on non-aggressive setting
            {
               firstprio = c_PB_Nexus;
               secondprio = c_PB_Gateway;
               thirdprio = c_PB_WarpGate;
            }
            //Find targets
            g2 = AIFindUnits(player, firstprio, UnitGetPosition(u1), r, c_noMaxCount);
            g2 = AIGetFilterGroup (af1, g2);
            if(UnitGroupCount(g2,c_unitCountAlive) == 0)
            {
               g2 = AIFindUnits(player, secondprio, UnitGetPosition(u1), r, c_noMaxCount);
               g2 = AIGetFilterGroup (af1, g2);
            }
            if(UnitGroupCount(g2,c_unitCountAlive) == 0)
            {
               g2 = AIFindUnits(player, thirdprio, UnitGetPosition(u1), r, c_noMaxCount);
               g2 = AIGetFilterGroup (af1, g2);
            }
            if(UnitGroupCount(g2,c_unitCountAlive) != 0)
            {
               u2 = UnitGroupUnit(g2,1);
               OrderSetTargetUnit(o1,u2);
               AICast (u1, o1, c_noMarker, false);
            }
         }
      }
      i = i + 1;
   }
}


It loops through all Nexi on each call and selects a good target for each one.
#10
I do believe the marker indicates either a) that the casting unit is marked as "casting" so it isn't issued another cast order or b) that the target unit is marked so that other casting units won't double-cast on the same one.


You can also use c_noMarker in that slot and handle the target marking yourself.
#11
OK so now say I have a point, how do I get the x and y coordinates of that point?


is it point.x or point.X or point.x() or point.X() or point.GetX()
#12
Name says it all, I want to know how to check how many units/upgrades are in the build queue at a particular building. I'm writing a Chrono Boost func that prioritizes based on what units are being built.
#13
AI Help Section / Re: Help...
March 06, 2010, 07:29:18 PM
This can occur if there is an error in your AI files or if the map isn't AI hacked I think.




Also, this should be in "AI Help Section"
#14
AI Development / Re: Galaxy syntax validator
March 06, 2010, 07:09:36 AM
i <3 u
#15
Or generate any static Point value?


I can't do:
point p;
p = new point(0,0);


any idea?