Page 2 of 3

Posted: 16 Nov 2005, 23:31
by jcnossen
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.

Posted: 16 Nov 2005, 23:51
by krogothe
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!

Posted: 17 Nov 2005, 20:57
by AF
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

Posted: 17 Nov 2005, 22:02
by krogothe
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 :lol: but hey it could turn out to be a kickass AI :roll: ?

Posted: 17 Nov 2005, 22:05
by jcnossen
Don't cheer to soon, have you used STL templates here? If not, the possible differences between 2005 and 2003 implementations may still break your AI.
Good luck though, I hope it still works out.

Posted: 17 Nov 2005, 23:05
by krogothe
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

Posted: 18 Nov 2005, 07:30
by Maelstrom
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.

Posted: 18 Nov 2005, 12:33
by krogothe
:o

Posted: 18 Nov 2005, 12:39
by SwiftSpear
AI construction is like the ultimate nerd tournament. Win AI!

Posted: 18 Nov 2005, 14:33
by krogothe
:/ how do i make my units build something???
i had a look at various AIs, but it just isnt working!
can someone post a sample code of how to make the commander build a building close to him?

Posted: 18 Nov 2005, 15:01
by jcnossen

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

Makes the commander build a mex where he is standing right now.

Posted: 18 Nov 2005, 16:10
by krogothe
Thanks a bunch its building now!

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?

Posted: 18 Nov 2005, 20:23
by AF
If you wanna build a unit from a factory you can give it any locations you want as long as its a valid location.

Posted: 18 Nov 2005, 23:00
by daraknor
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.

help?

Posted: 18 Nov 2005, 23:32
by krogothe
:o

Posted: 19 Nov 2005, 10:35
by Berion
.\ResourceControl.cpp(23) : error C3861: 'SQRT': identifier not found
use sqrt() and #include <cmath>
.\ResourceControl.cpp(19) : error C2065: 'callback' : undeclared identifier
callback isn't defined in GetEnergyScore

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)
{
...
}
and

Code: Select all

class CGlobalAI : public IGlobalAI  
{
...
float GetEnergyScore (int unitID);
..
}
or

Code: Select all

float GetEnergyScore (IGlobalAICallback* callback,int unitID)
{
...
}
try this and ist should work. :-) I hope you understand everything, because my english is bad. :-D
also, how do i turn a line like "callback->GetAICallback()" to simply "cb" like its done in other AIs?
I am not sure, butthis should work:

Code: Select all

IAICallback* cb = callback->GetAICallback();
I want to try my own ai and I have question: I want that the com starts building something.

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);
Where should I put this? CGlobalAI::Update()? UnitCreated(int unit)?

And why is CGlobalAI::UnitIdle(int unit) never called?

Alex

Posted: 19 Nov 2005, 14:22
by krogothe
:o

Posted: 19 Nov 2005, 17:24
by Berion
Okay it compiles now but if I run it I get an unhandled exception error!
Can you post the unhandled exception error?
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?
If you can compile the code, it dosn't matter.

Code: Select all

float Score = (Production/((Cost+IncomeMultiplier*CurrentIncome)* Cost))
*sqrt (sqrt (Production)* sqrt (sqrt ((Hitpoints*Hitpoints)/Cost))); 
Check if Cost, ((Cost+IncomeMultiplier*CurrentIncome)* Cost) and the other floats are 0.

Alex

Posted: 19 Nov 2005, 17:47
by AF
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

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


Where G->cb-> could easily be replaced with cb->, and maybe a cache for untidefs so it doesnt have to be recalculated.

Posted: 19 Nov 2005, 18:27
by krogothe
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 :lol:

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