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

#1
So pointers do work...?

and... Yes, it will hold the value across function calls. But if you're not too keen on pointers, I would suggest getting more familiar w/ them outside of your AI project. Cuz as we all know, constantly loading and reloading SC and moving files in and out of MPQ editors is a pain in the ass, and pointers can be hairy to work w/ at first. I'd suggest playing around w/ em in C w/ a compiler.

..but what you got there works. In short.. just make sure your not assigning to or dereferencing values out of your arrays range.
#2
IF pointers are supported ...I don't know if they are, yet to play with them

void func (string OrderList, int *OrderCount, int *OrderPrio)

Say you want to pass this array

int[x] IntArr;

pass like this


//pointer to first element in the array
void func (..., IntArr, ...)


or for other elements in the array


//pointer to elements at position x
void func (..., IntArr + x, ...)
#3
have you tried .first and .second

Looking at the point type, it could just be a kind of typedef of pair<int, int>... I've yet to mess around w/ points or anything yet, so I've not tested any of this, try it out though, perhaps it works.
#4
AI Development / Re: Help With Functions
March 07, 2010, 06:59:14 PM
hd: Sry, Copy/paste error, check out the OP last section that's how it's supposed to look, but thx much for the help..

also... I got things running, turns out my problem was w/ sumthing completely different...

I commented out a block using /* ..... */

I guess it is illegal to use this method of commenting...? I used line by line commenting, and poof it works... But the section about Clearing and Enabling Stock helped tons..

thx again
#5
AI Development / Re: Variable Arrays...
March 06, 2010, 06:07:15 PM
This is what I figured out so far about arrays

Declaring...

int[2] IntArr;

string[2] StringArr;



Havent found out how to initialize yet... Perhaps this is not possible.
for example like..


//Doesn't seem to be possible

int int1 = 1, int2 = 2;

int[2] IntArray = { int1, int2 }


Assigning... You must assign in a non-global scope


//Declared in Global Scope

int[2] IntArr;
string[2] StringArr;

void MessWithArrays(){

   //Local Scope

   IntArr[0] = 1;

   StringArr[0] = "String";

   
   int ArrIndex = 0;
   while(ArrIndex != 2){

       UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText(IntToString(IntArr[ArrIndex])));

       UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText(StringArr[ArrIndex]));

       ArrIndex = ArrIndex + 1;

   }
}



If you were to run AI with MessWithArrays() to test, you'll see this text when it is called...

1
0
String
(blank)

IntArray[0] = 1
IntArray[1] (default int initialization 0)
StringArray[0] = "String"
StringArray[1] (default string initialization "")


#6
AI Development / Re: Help With Functions
March 05, 2010, 01:49:15 PM
thx thx alot! ;D  i'mma have to mess round w/ this later today..  I'm not concerned about the actual functionality or strategy at this point, just figuring out the flow of everything, I'll pop back if I figures out anything neat, but this helps alot thx again.
#7
AI Development / Re: Help With Functions
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..

copy and paste error... fixed below

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, Yuna, I'll probably be using that for counting soon enough


if(AITechCount(player, c_PU_Probe, c_techCountCompleteOnly)<10{
       AISetStock(player,10, c_PU_Probe);

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

       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);
}
#8
AI Development / Help With Functions
March 05, 2010, 10:09:35 AM
In an attempt to set up an AI, I started off by writing some functions just to test... Here they are

//==================================================================================================
// My Functions
//==================================================================================================

void Message(int player, string msg){
  int i = FixedToInt(AIGetTime());
  msg = PlayerRace(player) + " " + IntToString(player) + msg + " Time = " + IntToString(i);
  UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText(msg));
}

void One(int player){
  string msg = "Func One";
  Message(player, msg);
}

void Two(int player){
  string msg = "Func Two";
  Message(player, msg);
}

void Three(int player){
  string msg = "Func Three";
  Message(player, msg);
}

The file is included in Protoss.GALAXY...

//==================================================================================================
// Protoss Melee AI
//==================================================================================================

include "TriggerLibs/Protoss0"
include "TriggerLibs/MyProtoss"

//-----------------------------------------------------------------------------------
// Counter-Attack Units
//-----------------------------------------------------------------------------------

And I call them here...

//-----------------------------------------------------------------------------------
// AIMeleeProt
//-----------------------------------------------------------------------------------

void AIMeleeProt (int player) {
  int mainState = AIState(player, e_mainState);
  if (mainState == e_mainState_Init) { ProtossInit(player); }
  One(player);
  Twoplayer);
  Three(player);
}

They work as intended as they are above, but then I decided to try to make them function for building, the game doesn't take... Here's what I was attempting to do....

//==================================================================================================
// My Functions
//==================================================================================================

void Message(int player, string msg){
  int i = FixedToInt(AIGetTime());
  msg = PlayerRace(player) + " " + IntToString(player) + msg + " Time = " + IntToString(i);
  UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText(msg));
}

void One(int player){
  AIClearStock(player);

  if(AITechCount(player, c_PU_Probe, c_techCountCompleteOnly) < 8){
    AISetStock(player, 8, c_PU_Probe);
  }

  string msg = "Func One";
  Message(player, msg);
}

void Two(int player){
  AIClearStock(player);

  if(AITechCount(player, c_PU_Probe, c_techCountCompleteOnly) >= 8){
    AISetStock(player, 1, c_PB_Pylon);
    AISetStock(player, 1, c_PB_Assimilator);
    AISetGasPeonCountOverride(player, c_townMain, 3);
  }

  string msg = "Func Two";
  Message(player, msg);
}

void Three(int player){
  AIClearStock(player);

  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);
  }

  string msg = "Func Three";
  Message(player, msg);
}

I beleive I need to set a state before I can start calling stock functions, or I need to call them from another place.. I tried alot of different things, but I can't figure it out. Anyone have an explaination on setting up an entry for this kind of call. I would really appreciate any help ;)

#9
AI Development / Re: AI Script Editing Tool
March 03, 2010, 09:56:40 AM
While putz'n around with all the AI files, I decided to write a lil program to quickly convert the .GALAXY files to .C (can convert from .GALAXY to basicly any text format, and from whatever format back to .GALAXY... i like the syntax highlighting, reading the files in VC). IDK if you guys would have a use for it, but it serves it's purpose for me quite well. Check it out if you wish...

http://www.mediafire.com/?hyow1m2o2mw

Also, looking at the AI, was wondering if I could help you guys in any way.. I've very little knowledge of the code, but i believe I can figure out how to implement some functions, and figure out their uses. Only idea I have is to have many individuals look at small sections, implement the functions in that section, and report on functionality. If you're doing sumthing along these lines, send me an eMail.

anyhow... thx for the AI's and gj ..few pics of what the program does, if interested

http://i259.photobucket.com/albums/hh296/SPMAC/Before.png
http://i259.photobucket.com/albums/hh296/SPMAC/batch.png
http://i259.photobucket.com/albums/hh296/SPMAC/After.jpg