Page 1 of 2
IAICheats
Posted: 20 Dec 2005, 13:52
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?
Posted: 20 Dec 2005, 16:04
by jcnossen
Look at the global AI header files...
Posted: 20 Dec 2005, 16:54
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();)
Posted: 20 Dec 2005, 18:08
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.
Posted: 20 Dec 2005, 18:19
by krogothe
I have all the checks in place already, it was just the set<int>enemies...
Thanks
Posted: 20 Dec 2005, 18:20
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.
Posted: 20 Dec 2005, 18:27
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....
Posted: 20 Dec 2005, 19:00
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?
Posted: 20 Dec 2005, 19:51
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?
Posted: 20 Dec 2005, 20:07
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
Posted: 21 Dec 2005, 00:51
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?
Posted: 21 Dec 2005, 05:05
by Chocapic
No, ppl actually try to develop a decent ai before trying to put an ai to cheat.
Posted: 21 Dec 2005, 12:52
by krogothe
Your comment added so much to the topic choca, thanks a lot!
Posted: 21 Dec 2005, 13:16
by smokingwreckage
I LIKE cheating AIs.
Posted: 21 Dec 2005, 13:55
by Das Bruce
I like AI's that give you a meaningful strategic challenge.
Posted: 21 Dec 2005, 13:58
by Torrasque
I like having different type of AI

Posted: 21 Dec 2005, 14:09
by Masse
I like AI's

Posted: 21 Dec 2005, 20:43
by Triaxx2
I like Spring.
Posted: 21 Dec 2005, 21:20
by Masse
I like SY's
Posted: 21 Dec 2005, 21:44
by krogothe
I like spamming