AIs: Ideas for how to fix this AI problem?

Discussion of all aspects of multiplayer development: unit balancing, map development, server development, and so forth.

Moderator: Forum Moderators

Post Reply
Varthonai
Posts: 8
Joined: April 14th, 2007, 9:08 pm

AIs: Ideas for how to fix this AI problem?

Post by Varthonai »

It's starting to annoy me that the AI does not have a clue how to respond to units with Ambush or Nightstalk, or any other ability that makes units hide. I once fought the AI while playing Rebels, and it was Northerners; I retreated a Wose who had only 5HP left from its battle with a Goblin Knight, moving him three hexes away, into a single space of Forest surrounded on all sides by grassland.

Any human player would have realized that there was obviously a weak unit hidden in that Forest, since the Wose could clearly be seen going in. But since the AI apparently doesn't process the significance of animations, the Goblin Knight proceeded to leave the injured Wose and attack my fully-recovered, village-stationed Elvish Champion instead, and got killed for its trouble.

Is there an AI that recognizes hide-related stuff like this? If so, where could I download it? If not, does anyone have ideas for how to go about writing one?
"Don't you worry about cancer?"
"I AM cancer. I do not frighten myself."
User avatar
eyerouge
Posts: 380
Joined: June 29th, 2007, 4:37 am
Location: wtactics.org
Contact:

Re: AIs: Ideas for how to fix this AI problem?

Post by eyerouge »

Varthonai wrote:Is there an AI that recognizes hide-related stuff like this? If so, where could I download it? If not, does anyone have ideas for how to go about writing one?
I don't code in wesnoth lingo, but if I'd do it my imaginary language I'd do it like this:

At end of each turn the current players units will all memorize the position of all enemy units they actually do see. This is done by using variable arrays or whatever.

Your Turn 1: You stand within sight of the AI with your damaged Wose. AI:s units "memorizes" your Woses position.

Your Turn 2: You move a damaged Wose into a forest. This happens every single hex your unit moves -> Because your unit was within sight of the enemy it is on a checklist. The checklist tells the game to let the AI memorize your units new position if and only if it's within sight range of any of the AI:s units. That way, when you move the Wose 3 hexes, hex 1 will be "seen" by the AI, hex 2 also, but hex 3 won't since it will result in the Woses hiding in the forest. So, the last thing the AI will know about your position is that it was on hex 2.

The next step is to make that information useful for the AI and make it worthy its name ;) The AI didn't only see in what direction you moved and vanished, it also saw what kind of unit it was that you moved. Hence the AI must come to the same conclusion as a real player would, seeing you do that maneuver - that you're not far away. How would the AI know that? Easy, he knows 1) how many hexes he saw you move 2) next to what hex you disappeared. Now, if the AI really wants to find you like a real player would, he'd a) draw a circle radius that has the length of the number of moves your unit had left / 2 and b) check how many hexes within that area that has forest in it c) launch units of his own to cover those hexes and reveal you so he can finish you off.

That's the basics done my way in wrapped up sloppy. = P You'd of course wan't to add a million other things as well to not make the AI fall for traps etc, but that's another story.
Post Reply