Implementing invisibility in AI

Brainstorm ideas of possible additions to the game. Read this before posting!

Moderator: Forum Moderators

Forum rules
Before posting a new idea, you must read the following:
Post Reply
mpolo
Posts: 113
Joined: June 15th, 2004, 8:18 pm

Implementing invisibility in AI

Post by mpolo »

I find it a little frustrating that the AI always knows *precisely* where all of my "invisible" units are. I was thinking about easy kludges to make this at least a little believable... (A real solution to the invisibility problem is, admittedly, quite difficult.)

What if the AI assumes that each invisible unit that was visible in the previous turn is somewhere within 2-3 hexes of its actual position (if we're talking about a unit that is only invisible in certain terrains, then limit this to the hexes in this radius that have the appropriate terrain) -- when it sends a unit to attack, it goes for that spot. If it is not "ambushed", then it makes another guess.

If the unit was not visible in the previous turn, then it should be a complete unknown to the AI, so that the AI does not consider it at all in its attack and defense calculations.

I think this would at least make it seem plausible that the AI doesn't really know where my units are, but at the same time not make it totally stupid -- "Hmm... that Elvish Ranger just disappeared... couldn't possibly be hiding in this little copse right next to my castle..."

Anyway, this a rough idea, but maybe it inspires someone. If I ever get a lot of extra time, I might try to actually look at the code and see if I can hack out an example, but I wouldn't count on that happening soon...
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Implementing invisibility in AI

Post by zookeeper »

mpolo wrote:I find it a little frustrating that the AI always knows *precisely* where all of my "invisible" units are. I was thinking about easy kludges to make this at least a little believable... (A real solution to the invisibility problem is, admittedly, quite difficult.)
I was under the impression that the AI only knows the location of your leader even if it's hidden, not your regular units (which it seems to forget/ignore entirely if they're hidden).

Otherwise your idea sounds pretty good.
mpolo
Posts: 113
Joined: June 15th, 2004, 8:18 pm

Post by mpolo »

Maybe he just got lucky then -- it just looked a couple of times like he went straight for the invisible troop, even ignoring the convenient target I had put to distract him... In any case, I think the idea is sound as a way to make it more like the AI is dealing with invisibility "fairly" (for both sides...)
User avatar
Aethaeryn
Translator
Posts: 1554
Joined: September 15th, 2007, 10:21 pm
Location: Baltimore, Maryland, USA

Post by Aethaeryn »

I successfully hid my elvish ranger leader from the AI once. Maybe you were just blocking the path the AI was going to take anyway with your invisible units? Alternatively, I could've just moved my ranger too far out of the way in a fog-of-war game.
User avatar
Ken_Oh
Moderator Emeritus
Posts: 2178
Joined: February 6th, 2006, 4:03 am
Location: Baltimore, Maryland, USA

Post by Ken_Oh »

I'm actually pretty sure that AI doesn't have a clue where your hidden units are. Of course, the map can make it look like they find them all the time.

I specifically remember playing Battle World in 1.1.x where I hid a bunch of Elvish Avengers in the forest to the west, within one turn's reach of the Orcs just east of there. I waited for the Orcs to recruit one big set and then send them north after which I waited a couple rounds and then pounced on the leader. It was really clear that the AI wasn't expecting it, and sent all of its units to backtrack.

Do you have any counter examples? I'm not saying your proposal isn't a good either either, I'm just not sure the AI works like you think it does. Someone should do some tests to get a definitive answer.
User avatar
Baufo
Inactive Developer
Posts: 1115
Joined: January 29th, 2006, 4:53 pm
Location: Vienna, Austria

Re: Implementing invisibility in AI

Post by Baufo »

mpolo wrote:I think this would at least make it seem plausible that the AI doesn't really know where my units are, but at the same time not make it totally stupid -- "Hmm... that Elvish Ranger just disappeared... couldn't possibly be hiding in this little copse right next to my castle..."
Well, that is all nice and soundly in theory but it is very hard to teach a computer such kind of things.
I was working on the proof of one of my poems all the morning, and took out a comma. In the afternoon I put it back again. -- Oscar Wilde
mpolo
Posts: 113
Joined: June 15th, 2004, 8:18 pm

Re: Implementing invisibility in AI

Post by mpolo »

Baufo wrote: Well, that is all nice and soundly in theory but it is very hard to teach a computer such kind of things.
That's why I provided a pseudo-algorithm: the computer AI "guesses" where the unit is and gets it right within 2-3 hexes. That gives enough error that he can't just home in, but doesn't have him totally ignoring units that sneak up on him. Of course, no human could keep track of where the invisible unit might be for more than 1-2 turns, so I proposed that the computer be made oblivious to the unit on the second turn in a row that it was invisible.

It's not a perfect algorithm -- you could use an invisible unit just out of range to draw off the enemy, then move it to another spot where it's invisible, yet closer, and still snipe him. But I think it's better than nothing...
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

IIRC the AI ignores fog-of-war and shroud. So that couldn't be the explanation of why it didn't attack you...
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
Post Reply