how to start the AI
Moderators: hoijui, Moderators
Using VS 2005 (Everyone here is using 2003) might give problems, but finding windows.h should just work because it's so standard. Are you using the free downloadable compiler pack by any chance? Because that one doesn't have system headers like windows.h. You'll have to download the Platform SDK as well.
yeah i was reading about in MSDN and thats what it said... the SDK isnt included in the express editions (damn me i deleted my 4GB worth of MSDN and visual studio.net a while ago).
Ill find out pretty soon!
EDIT:
I installed every single SDK version there was, wasted GBs of bandwidth and hours of my time, it still wont f***ing work, Im gonna delete every single tiny trace of visual studio and its SDKs and the AI projects, get visual studio 2003 and start over...
Should i get the bigger enterprise architect version or the normal one? and is VS 2003 = VS.net?
just want to make sure i have EXACTLY what you guys have!
Ill find out pretty soon!
EDIT:
I installed every single SDK version there was, wasted GBs of bandwidth and hours of my time, it still wont f***ing work, Im gonna delete every single tiny trace of visual studio and its SDKs and the AI projects, get visual studio 2003 and start over...
Should i get the bigger enterprise architect version or the normal one? and is VS 2003 = VS.net?
just want to make sure i have EXACTLY what you guys have!
Actually I used to use the free compiler, with codeblocks, it compiled everythign fien or at least i thought. The AI never got laoded. It turns out everytime the engien checked the interface version the AI returned a zero instead of what ti was coded to do. The problem dissapeared as soon as I started to use VS .Net 2003
WOOT
http://putfile.com/pic.php?pic=11/32014571725.jpg&s=x2
It was so easy this time... with VS 2005 it just compiled straight away, no errors, no problems and actually worked in-game. I got so much work to do on it but heck at least i got hopes now!!
I cant thank you guys enough! Ill need loads of help though since i have ZERO experience in programming and coding
but hey it could turn out to be a kickass AI
?
It was so easy this time... with VS 2005 it just compiled straight away, no errors, no problems and actually worked in-game. I got so much work to do on it but heck at least i got hopes now!!
I cant thank you guys enough! Ill need loads of help though since i have ZERO experience in programming and coding


Break my AI? well i did update the source files to 2005 standard, and the AI seems to run fine, I just made a little method to display tells me if an AI unit is damaged, giving damage, unit IDs etc.
Would this problem with STL templates still pop up?
It is also being pretty hard to get my head around how to manage units (since im trying to make the AI compatible with ANY mod, reading the unit's stats much like AAI) and how to make it efficient...
LOTS of playing around with the interface to be done still, i need to know exactly how each bit works :) so far its been good!
Im testing all the report functions (eg resources, income, etc) so i can start writing the economy handler.
Ill be using a VERY nifty algorithm for it that will provide optimal growth at ANY time with ANY mod in ANY situation (provided you have builder units). I got it working on paper, but need to find the right equation to use, and damn its hard!
When i get it working ill let you guys know.
How does the system to build the next resource building work on your AIs? Does it take into account the cost and building time of each of them?
EDIT:
Nevermind, it took me 4 sides of A4 full of equations and a massive excel spreadsheet, but from the tests it seems to be the perfect model for picking the right resource buildings at the right time. If it works out fine it should provide the optimal growth of the AI's economy, beating any player or AI in income at any given time!
Hope it damn works, took me ages!
Once i find out how to make the AI actually build and how to extract unit information such as cost/speed/HP/buildtime etc I should put it to test!
http://putfile.com/pic.php?pic=11/32019443767.gif&s=x2
Would this problem with STL templates still pop up?
It is also being pretty hard to get my head around how to manage units (since im trying to make the AI compatible with ANY mod, reading the unit's stats much like AAI) and how to make it efficient...
LOTS of playing around with the interface to be done still, i need to know exactly how each bit works :) so far its been good!
Im testing all the report functions (eg resources, income, etc) so i can start writing the economy handler.
Ill be using a VERY nifty algorithm for it that will provide optimal growth at ANY time with ANY mod in ANY situation (provided you have builder units). I got it working on paper, but need to find the right equation to use, and damn its hard!
When i get it working ill let you guys know.
How does the system to build the next resource building work on your AIs? Does it take into account the cost and building time of each of them?
EDIT:
Nevermind, it took me 4 sides of A4 full of equations and a massive excel spreadsheet, but from the tests it seems to be the perfect model for picking the right resource buildings at the right time. If it works out fine it should provide the optimal growth of the AI's economy, beating any player or AI in income at any given time!
Hope it damn works, took me ages!
Once i find out how to make the AI actually build and how to extract unit information such as cost/speed/HP/buildtime etc I should put it to test!
http://putfile.com/pic.php?pic=11/32019443767.gif&s=x2
Will you be releasing the AI as open source? Cause if this algorithim works as well as you say it does, I think many people will want to use it. If they give you proper credits of course. Couple this with Cain's Metal Class thing, and you have an instant economy. Plus open source is cool, as people can help you with any problems you have.
- SwiftSpear
- Classic Community Lead
- Posts: 7287
- Joined: 12 Aug 2005, 09:29
Code: Select all
float3 pos=cb->GetUnitPos(comID);
Command c;
c.id = -cb->GetUnitDef ("CORMEX")->id;
c.params.push_back (pos.x);
c.params.push_back(0.0f):
c.params.push_back (pos.z);
cb->GiveOrder (comID, &c);
Thanks a bunch its building now!
I changed the code so it would work:
I messed up with the GetUnitDef ("ARMMEX")->id before thats why it wouldnt work!
does that work for factories building units as well?
I changed the code so it would work:
Code: Select all
float3 pos=callback->GetAICallback()->GetUnitPos(4998);
Command c;
c.id = -callback->GetAICallback()->GetUnitDef ("ARMMEX")->id;
c.params.push_back(pos.x);
c.params.push_back(pos.y);
c.params.push_back(pos.z);
callback->GetAICallback()->GiveOrder (4998, &c);
I messed up with the GetUnitDef ("ARMMEX")->id before thats why it wouldnt work!
does that work for factories building units as well?
Have you looked into bayesian algo for weighting efficiency? It allows for some nifty stuff like saying:
This situation is 75% similar to a previous one where tactic X was used with 65% efficiency and was successful 80% of the time with a 5% chance of failure and 20% losses on success. Weighted against another situation at 25%, 95%, 25%, 40% and 10% which tactic should be used?
The beauty is that the math is simple, but very effective. The advantage is that it is modules xased and would be able to change out components , tell us the efficiency of the new version and use bothor either. We may want to make our systems similar enough that they could use each other's modules and/or switch out the "Intelligence" component.
This situation is 75% similar to a previous one where tactic X was used with 65% efficiency and was successful 80% of the time with a 5% chance of failure and 20% losses on success. Weighted against another situation at 25%, 95%, 25%, 40% and 10% which tactic should be used?
The beauty is that the math is simple, but very effective. The advantage is that it is modules xased and would be able to change out components , tell us the efficiency of the new version and use bothor either. We may want to make our systems similar enough that they could use each other's modules and/or switch out the "Intelligence" component.
use sqrt() and #include <cmath>.\ResourceControl.cpp(23) : error C3861: 'SQRT': identifier not found
callback isn't defined in GetEnergyScore.\ResourceControl.cpp(19) : error C2065: 'callback' : undeclared identifier
IGlobalAICallback* callback; is a member of class CGlobalAI
make float GetEnergyScore (int unitID) also a member of CGlobalAI:
Code: Select all
float CGlobalAI::GetEnergyScore (int unitID)
{
...
}
Code: Select all
class CGlobalAI : public IGlobalAI
{
...
float GetEnergyScore (int unitID);
..
}
Code: Select all
float GetEnergyScore (IGlobalAICallback* callback,int unitID)
{
...
}

I am not sure, butthis should work:also, how do i turn a line like "callback->GetAICallback()" to simply "cb" like its done in other AIs?
Code: Select all
IAICallback* cb = callback->GetAICallback();
Code: Select all
float3 pos=callback->GetAICallback()->GetUnitPos(4998);
Command c;
c.id = -callback->GetAICallback()->GetUnitDef ("ARMMEX")->id;
c.params.push_back(pos.x);
c.params.push_back(pos.y);
c.params.push_back(pos.z);
callback->GetAICallback()->GiveOrder (4998, &c);
And why is CGlobalAI::UnitIdle(int unit) never called?
Alex
Can you post the unhandled exception error?Okay it compiles now but if I run it I get an unhandled exception error!
If you can compile the code, it dosn't matter.Also this function is in the ResourceHandler.cpp file. The ResourceHandler.h file is currently empty. Shouldnt I have to put a prototype function in it or something?
Code: Select all
float Score = (Production/((Cost+IncomeMultiplier*CurrentIncome)* Cost))
*sqrt (sqrt (Production)* sqrt (sqrt ((Hitpoints*Hitpoints)/Cost)));
Alex
msg = "build" should be msg == "build".
I'd prefer it if modules took the form NTAI uses. All classes in NTAI exept helpers follow the same functiond eriving from T_Agent which is a copy of IGlobalAI with an Add() and Remove() function. Taking a Global structure instead of an IGlobalAICallback structure on InitAI.
I find a class such as this would be a much better
Where G->cb-> could easily be replaced with cb->, and maybe a cache for untidefs so it doesnt have to be recalculated.
I'd prefer it if modules took the form NTAI uses. All classes in NTAI exept helpers follow the same functiond eriving from T_Agent which is a copy of IGlobalAI with an Add() and Remove() function. Taking a Global structure instead of an IGlobalAICallback structure on InitAI.
I find a class such as this would be a much better
Code: Select all
struct cscore{
int energy;
int mex;
int attacker;
int defender;
int builder;
int factory;
int scouter;
};
class cscorer : public base {
public:
scorer()
~scorer()
void InitAI(Global* GL);
cscore Score(UnitDef* u);
cscore Score(int unit);
private:
int energyscore(UnitDef* u);
//... and so on
Global* G; // if not NTAI use IAICallback* cb;
};
Yes, every line of code in my AI atm is complete shambles!
Id love to organize my AI better but I have no idea what half of what you wrote does (yes i know the ~ is a destructor and that * means a pointer but i dont know how they work yet). Ill definitely make a scorer class once i know how!
Im reading a book on it atm
The exception error is just that, a message box saying you have an unhandled exception error and that you should contact the AI programmer...
Ill keep trying and reading on C++
Id love to organize my AI better but I have no idea what half of what you wrote does (yes i know the ~ is a destructor and that * means a pointer but i dont know how they work yet). Ill definitely make a scorer class once i know how!
Im reading a book on it atm

The exception error is just that, a message box saying you have an unhandled exception error and that you should contact the AI programmer...
Ill keep trying and reading on C++