Ay, what an AI!!

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
Geos
Posts: 115
Joined: March 20th, 2008, 1:58 pm
Location: Italy

Ay, what an AI!!

Post by Geos »

I coded this way a neutral side on an scenario.
My intention is to have a neutral side that only retreats, or at least doesn't go and attack the enemy. I also wanted to keep the leader out of the keep, so the player can use it to recruit. With these settings I get an AI that attacks the enemy, and a leader that moves away from it's original position, that is, don't know why, the keep (the keep is not in 25, 16). What am I doing wrong? I went through the documentation and follow it.

Code: Select all

[side]
type=Mage
description=Kaliostali
user_description= _ "Kaliostali"
x = 25
y = 16
share_view=yes
side=2
canrecruit=0
gold=50
team_name=humans
[ai]
agression=-1
caution=1
leader_value=0
passive_leader=yes
	[avoid]
	x = 9
	y = 13
	[/avoid]
[/ai]
[/side]
[side]
type=Mage
description=Kaliostali
user_description= _ "Kaliostali"
x = 25
y = 16
share_view=yes
side=2
canrecruit=0
gold=50
team_name=humans
[ai]
agression=-1
caution=1
leader_value=0
passive_leader=yes
[avoid]
x = 9
y = 13
[/avoid]
[/ai]
[/side]
That's ridiculous, dragons have no windows...
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: Ay, what an AI!!

Post by AI »

aggression=-1 means it considers its own units twice as important as the enemies, meaning it will still attack if it can do more than twice the damage it receives and not terribly expose itself (the caution).

It may help to set [target] to 0 (or lower, if possible) to all other sides.

Also, I've found that skirmishing units ignore [avoid] tags.
User avatar
Mist
Inactive Developer
Posts: 753
Joined: February 15th, 2007, 8:44 am
Location: Milton Keynes, UK

Re: Ay, what an AI!!

Post by Mist »

In 1.4 it's impossible to create an AI behaving as you want it to do. The most you can achieve is one that values its units much higher than enemys and attacks very rarely and with overhelming numbers (caution and agression keys).
Pasive leader sets AI leader passive (meaning not moving), [avoid] tells it not to place units on hexes specified inside (but it will still attack enemy on them), leader value sets relative value in comparison to other units (not absolute targetting one), [target] basicaly serves the same purpose.

The most you can achieve is an AI that withdraws following a scheudle (by setting an [ai] for each turn with increasingly larger [avoid] area)
Somewhere, between the sacred silence and sleep.
Disorder.
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Re: Ay, what an AI!!

Post by turin »

Mist wrote:The most you can achieve is an AI that withdraws following a scheudle (by setting an [ai] for each turn with increasingly larger [avoid] area)
But if in doing this you make it so one of the AI's units cannot move anywhere not in the [avoid] area, it'll just sit there doing nothing, not retreat... at least last time I checked it was like that.
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
User avatar
Mist
Inactive Developer
Posts: 753
Joined: February 15th, 2007, 8:44 am
Location: Milton Keynes, UK

Re: Ay, what an AI!!

Post by Mist »

True, that's why the [avoid] area can't grow rapidly, and even then you won't be able to support border case scenarios like unit stuck in ZoC or behind an impassable terrain strech. It's going to get much easier in 1.5 with formula AI and ability to modify [ai] in events.
Somewhere, between the sacred silence and sleep.
Disorder.
User avatar
Geos
Posts: 115
Joined: March 20th, 2008, 1:58 pm
Location: Italy

Re: Ay, what an AI!!

Post by Geos »

Ok....
agression and caution can have values higher or lower that -1 to 1?
How do I define an area. I tried with

Code: Select all

[avoid]
x > 9
y < 11
[/avoid]
But of course, wouldn't work. Would it be like x=9,10,11... and y=1,2,3... The number of combination can be quite big as the area gets groing, not talk about big maps...
That's ridiculous, dragons have no windows...
User avatar
Mist
Inactive Developer
Posts: 753
Joined: February 15th, 2007, 8:44 am
Location: Milton Keynes, UK

Re: Ay, what an AI!!

Post by Mist »

You can specify the ranges with -
for example
[avoid]
x=1-10
y=1-10
[/avoid]
will tell it to avoid hexes with 1 < x and y <10
Somewhere, between the sacred silence and sleep.
Disorder.
Rhuvaen
Inactive Developer
Posts: 1272
Joined: August 27th, 2004, 8:05 am
Location: Berlin, Germany

Re: Ay, what an AI!!

Post by Rhuvaen »

Also, spelling aggression with two 'g' will help wesnoth recognize the key, and set it to your preferred -1 and not 0.
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: Ay, what an AI!!

Post by AI »

actually, it's .5 by default, meaning it considers the enemy's units twice as important as its own.
Post Reply