How to make the AI Cheat

How to make the AI Cheat

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

Moderators: hoijui, Moderators

Post Reply
User avatar
Veylon
AI Developer
Posts: 174
Joined: 21 Sep 2005, 19:45

How to make the AI Cheat

Post by Veylon »

I hope that this hasn't been posted somewhere else, but here's how to make the AI Cheat without anyone having to type ".cheat".

You have to call the GetCheatInterface() from the GlobalAICallback you get in the GlobalAI::Init(). This returns a pointer to a AICheats class or NULL if in a multiplayer game (incidentally, making a check of whether or not the AI is in a multiplayer game).

If it returns the valid pointer, it also turns on cheating in the game.

So, add something like this to the GlobalAI class in the header:

Code: Select all

AICheats *Cheater;
bool Cheating;
bool NetworkGame;
And something like this to the Init function in the source:

Code: Select all

Cheater = GlobalAICallback->GetCheatInterface();
if(Cheater != NULL)
{
  // Can Cheat
  Cheating = NetworkGame = true;
}
else
{
  // Can't Cheat
  Cheating = NetworkGame = false;
}
I ran into this on accident whilst browsing the various AI *.cpps in the source.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

Im not sure if that piece of code is how it works right now.
I want to explain it a bit further for clarity:

Global AIs can always request the cheat interface now, and it will always provide one (even if .cheats isn't done by the user)
Another new behavior of the cheating support is the difference between passive cheats and active cheats. The AI can use passive cheats in a multiplayer game, and active+passive cheats in a singleplayer game. You can check this by calling:

bool CAICheats::OnlyPassiveCheats ()

I guess I forgot to put this in the changelog :roll:
User avatar
Veylon
AI Developer
Posts: 174
Joined: 21 Sep 2005, 19:45

Post by Veylon »

Well, it worked with 0.70b3, so I'll have to double-check it with 0.71b1. I'll bring a demo file or screenshots next time or else everyone can wait for the source code in OTAI's next version.

I've also found that it's possible for the AI to very easily get other players' data. Should that be something that's used, as in how the Starcraft AI and OTA AI always knew where your units were without having to explore? I've used to make the enemies units blow themselves up. I'll put up a replay of this next time.
User avatar
LOrDo
Posts: 1154
Joined: 27 Feb 2006, 00:21

Post by LOrDo »

Don't make your AI cheat, we want a smart AI, not a cheap AI.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Well XE8 is both, with cheating as an option and I'm sure OTAI will be too
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

KAI has been for months, the sheep shall follow :wink:
Its not a bad thing, currently AIs are way too easy for anyone who can even slightly play the game, so its just logical to up the difficulty until smarter behaviour is obtained...
Most of the AI cheat changes were because of me poking zaphod, gotta love him!
User avatar
Neddie
Community Lead
Posts: 9406
Joined: 10 Apr 2006, 05:05

Post by Neddie »

LOrDo wrote:Don't make your AI cheat, we want a smart AI, not a cheap AI.
I agree.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Type .aicheat to make NTai XE8 start cheating
User avatar
Veylon
AI Developer
Posts: 174
Joined: 21 Sep 2005, 19:45

Post by Veylon »

I wasn't thinking so much in terms as making hundreds of units coming out of thin air (as is interesting to see), as much as using information cheats, like finding out where the enemies are headed or seeing everything on the map. You know, the "traditional" AI advantages.

Also, I found a hack to get around the "Enemy entered LOS, but you can't see 'em" bug. That would surely be a fair use of hacking, right?

Anyway, I'll make up a config so that the player can tune OTAI's hacking however they want.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Looking at the source it seems the cheat interface isnt synced at all for active cheats, which is soemthing I'd like ammended.....
Post Reply

Return to “AI”