IAICheats

IAICheats

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

IAICheats

Post by krogothe »

How do i use it? It wont let me create an instance of it since its an abstract class, so what steps do i need to take to use any of the cheats for an AI?
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

Look at the global AI header files...
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

Right, thanks its working, but im getting this error:

Code: Select all

.\GlobalAI.cpp(143) : error C2664: 'int IAICheats::GetEnemyUnits(int *)' : cannot convert parameter 1 from 'std::set<_Kty>' to 'int *'
        with
        [
            _Kty=int
        ]
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
is this not right:

Code: Select all

	int* enemies = new int [5000];
	for(int i = 0; i < 5000; i++)
		enemies[i]=0;
	int numofenemies = cheat->GetEnemyUnits(enemies);
(where cheat = callback->GetCheatInterface();)
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

valgrind

Code: Select all

cheat = callback->GetCheatInterface();
if(cheat != 0){
   int* enemies = new int [5000]; 
   int numofenemies = cheat->GetEnemyUnits(enemies);
   if(numofenemies > 0){
      // ..... code here
   }
}
You missed out several checks, also whya re you setting all the array items to zero? You dotn need to, the function sets the values of the ones you need for you, and you're only gonna deal with numofenemies number of items. Cheats could also be zero/null pointer if the suer didnt type .cheats
Also I'd check that you havent defiend something such as set<int> enemies; somewhere else in the code. Try using something that isnt as generic as enemies anyways.
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

I have all the checks in place already, it was just the set<int>enemies...
Thanks
SoftNum
Posts: 22
Joined: 28 Nov 2005, 22:07

Post by SoftNum »

krogothe wrote:

Code: Select all

.\GlobalAI.cpp(143) : error C2664: 'int IAICheats::GetEnemyUnits(int *)' : cannot convert parameter 1 from 'std::set<_Kty>' to 'int *'
        with
        [
            _Kty=int
        ]
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
This error would seem to indicate that you are doing:

Code: Select all

set<int> enemies;
cheat->GetEnemyUnits(enemies);
Which is not syntactically equivilant.

AF's code sould work for what you're doing.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

hmm, I dont wanna create another thread but here I go

Code: Select all

try{
   G->Update();
}catch(){
    G->L->Eprint("Exception calling G->Update!");
}
That works fine for me, but I want instead to have

Code: Select all

G->Update();

void Global::Update(){
   try{
        A->Update
   }catch(){
      eprint("error in A");
   }
   try{
      F->Update();
   }catch(){
      eprint("error in R");
   }
}
The problem here is that when an exception occurs when G->Update is called, the game still crashes for some reason. I end up having to put G->Update as a whole in a try catch block in the CGlobalAI, which means if something happens in R->Update I dont get the emssage "error in R->Update" I get the message "error calling G->Update" because I've nested try and catch blocks inside eachother.

How do i get back to just puttign the individual agents in the global class in their own try blocks without it crashing when an exception occurs....
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

Alantai Firestar wrote:

Code: Select all

cheat = callback->GetCheatInterface();
if(cheat != 0){
   int* enemies = new int [5000]; 
   int numofenemies = cheat->GetEnemyUnits(enemies);
   if(numofenemies > 0){
      // ..... code here
   }
}
I did pretty much exactly that (but changing the name of the int array to avoid conflicts), and although it compiles just fine, i keep getting an AI exception whenever this line is run (it isnt run if cheats are off)

Code: Select all

int numofenemies = cheat->GetEnemyUnits(enemies);
It doesnt seem different to the code used by other AIs so whats the problem? do i have to declare special classes or something?
SoftNum
Posts: 22
Joined: 28 Nov 2005, 22:07

Post by SoftNum »

The big Z indicated that you might need to allocate 10000, not 5000 into the int array.

Do you have the callback trace that your code generates? Is it and access violation, or an assertion error or?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

He shouldnt get any errors witht hat code unelss there are 5000 or more untis ingame that arent allied to you.

Have you tried the same code but using the ordinary itnerface?

If all else fails and you have to ahve ti in there btu it's nto reliable put a try block around it
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

It works with the ordinary interface and a try block simply tells me what i already know, that the cheat interface seems fucked up...
Ill give it a full check tomorrow, try doing it in all different ways, etc... has ANYONE ever tried using it?
Chocapic
Posts: 556
Joined: 16 Oct 2005, 03:35

Post by Chocapic »

No, ppl actually try to develop a decent ai before trying to put an ai to cheat.
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

Your comment added so much to the topic choca, thanks a lot!
smokingwreckage
Posts: 327
Joined: 09 Apr 2005, 11:40

Post by smokingwreckage »

I LIKE cheating AIs.
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Post by Das Bruce »

I like AI's that give you a meaningful strategic challenge.
Torrasque
Posts: 1022
Joined: 05 Oct 2004, 23:55

Post by Torrasque »

I like having different type of AI ;)
User avatar
Masse
Damned Developer
Posts: 979
Joined: 15 Sep 2004, 18:56

Post by Masse »

I like AI's :P
User avatar
Triaxx2
Posts: 422
Joined: 29 Aug 2004, 22:24

Post by Triaxx2 »

I like Spring.
User avatar
Masse
Damned Developer
Posts: 979
Joined: 15 Sep 2004, 18:56

Post by Masse »

I like SY's
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

I like spamming
Post Reply

Return to “AI”