Why won't they attack it?
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.
Why won't they attack it?
I'm having trouble convincing units on one side (side 2) to attack the sole unit on the only enemy side (side 3). The would-be attackers are strong units at full health; their intended target is incredibly wimpy and is guaranteed to die in a single blow. Side 2 has the following ai tag:
[ai]
village_value=1000
aggression=1
[target]
side=3
value=50000
[/target]
[/ai]
I've tried this with and without simple targetting turned on. The very high village value is necessary for the scenario to work, so I figured an even higher target value would do the trick. As it is, they chase the tiny unit and often do move to kill it, but when it's surrounded on most (but not all) sides by units controlled by side 1, which is allied to side 2, they sometimes don't bother. I'm guessing the ai is figuring that the units on side 1 will take care of killing the tiny unit. Any ideas?
[ai]
village_value=1000
aggression=1
[target]
side=3
value=50000
[/target]
[/ai]
I've tried this with and without simple targetting turned on. The very high village value is necessary for the scenario to work, so I figured an even higher target value would do the trick. As it is, they chase the tiny unit and often do move to kill it, but when it's surrounded on most (but not all) sides by units controlled by side 1, which is allied to side 2, they sometimes don't bother. I'm guessing the ai is figuring that the units on side 1 will take care of killing the tiny unit. Any ideas?
This is a young gryphon. She likes cheese. She will steal all your cheese.
Hm. Don't know exactly, but astronomic values, especially for those "value"-type keys, might cause strange behaviour. In all the examples given, the values were applied with decimal points. I'd definitely try village_value=10 before I'd go further - it might already do what you want it to do (within the bounds of the AI capabilities).
Other than that, I guess Darth Fool's the man to answer.
Other than that, I guess Darth Fool's the man to answer.

Try some Multiplayer Scenarios / Campaigns
I'm running into similar difficulties, but without the large values Ringcaat was using. My goal is to make all of the units on side 3 make all-out, kamikaze attacks on a particular unit (here called George). I'd like them not to get "distracted" by tempting other targets along their paths, but they always do.
This is the side 3 WML I've been trying. I've tried commenting out various sections of it, but nothing seems to help.
[side]
side=3
controller=ai
no_leader=yes
[ai]
# Do everything possible to kill George
[target]
description=George
value=100
[/target]
aggression=1.0
caution=0.0
scout_village_targetting=0
village_value=0
simple_targetting=yes
grouping=no
[/ai]
[/side]
This is all on BFW 1.0.2. Any ideas would be a great help!
This is the side 3 WML I've been trying. I've tried commenting out various sections of it, but nothing seems to help.
[side]
side=3
controller=ai
no_leader=yes
[ai]
# Do everything possible to kill George
[target]
description=George
value=100
[/target]
aggression=1.0
caution=0.0
scout_village_targetting=0
village_value=0
simple_targetting=yes
grouping=no
[/ai]
[/side]
This is all on BFW 1.0.2. Any ideas would be a great help!
How about this?
Code: Select all
[ai]
#do everything possible to kill George
[target]
description=George
value=100
[/target]
#(hopefully) ignore everyone else
[target]
[not]
description=George
[/not]
value=0
[/target]
aggression=1.0
caution=0.0
scout_village_targetting=yes
village_value=0
simple_targetting=yes
grouping=no
[/ai]
"ILLEGITIMIS NON CARBORUNDUM"
Father of Flight to Freedom
http://www.wesnoth.org/wiki/FlightToFreedom
Father of Flight to Freedom
http://www.wesnoth.org/wiki/FlightToFreedom
- Elvish_Pillager
- Posts: 8137
- Joined: May 28th, 2004, 10:21 am
- Location: Everywhere you think, nowhere you can possibly imagine.
- Contact:
The AI ignores [target] whenever it has enemy units within reach of attack. Targets are only used by the AI to decide where to send units on multi-turn missions.
To make the AI madly pursue the death of a particular unit at close range, you can tamper with the victim's cost; if you make the unit cost 1000 gold, the AI will think it is extremely valueable to kill it. This still doesn't keep it from getting distracted on the way, when it can attack a different unit but can't attack the victim yet.
To make the AI madly pursue the death of a particular unit at close range, you can tamper with the victim's cost; if you make the unit cost 1000 gold, the AI will think it is extremely valueable to kill it. This still doesn't keep it from getting distracted on the way, when it can attack a different unit but can't attack the victim yet.
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
Yup, that pretty much describes the behavior I'm seeing. The AI generally heads towards the target unit, but if an easily-killable unit comes within range the AI veers off course to attack it. Changing the [target]s, as you say, doesn't affect this behavior.
Since my kamikaze unit won't necessarily be at close range, is there any way to convince the AI that attacking the other units is very costly/not worth it?
I suppose the workaround is just to have my kamikaze unit appear close to the target. Thanks for the idea about increasing the cost.
Since my kamikaze unit won't necessarily be at close range, is there any way to convince the AI that attacking the other units is very costly/not worth it?
I suppose the workaround is just to have my kamikaze unit appear close to the target. Thanks for the idea about increasing the cost.
I don't know what effect you're looking for, but wouldn't it be possible to:
- create a specific scenario ai in python that only recognizes 'George' as the enemy
or
- let the other units not really be there (during the AI's turn), this would require some heavy WML'ing but I think it's doable, especially if it's a smallish scenario.
[edit]
one example, with some drawbacks
- let there be three sides in the scenario when it's the AI's turn (main AI side, all-units-side - allied with AI, Goerge-side - AI's enemy) and two when it's the players side (main AI side and players side - all player units + George). This would have the negative (?) side effect of possibly applying allied healing and leadership from the all-units-side to the AI-side.
[/edit]
/tsr - just throwing in some ideas
ps. do a search for 'custom AI', if I don't recall wrong I think appelide helped turin with one, not to long ago (but probably the names are messed up, it's morning the brain is not fully booted :p)
- create a specific scenario ai in python that only recognizes 'George' as the enemy
or
- let the other units not really be there (during the AI's turn), this would require some heavy WML'ing but I think it's doable, especially if it's a smallish scenario.
[edit]
one example, with some drawbacks
- let there be three sides in the scenario when it's the AI's turn (main AI side, all-units-side - allied with AI, Goerge-side - AI's enemy) and two when it's the players side (main AI side and players side - all player units + George). This would have the negative (?) side effect of possibly applying allied healing and leadership from the all-units-side to the AI-side.
[/edit]
/tsr - just throwing in some ideas
ps. do a search for 'custom AI', if I don't recall wrong I think appelide helped turin with one, not to long ago (but probably the names are messed up, it's morning the brain is not fully booted :p)
Just throwing in more ideas: increase the cost of the target and the target value, but lower the ai's aggression somewhat and raise its caution. Maybe there is a balance you can strike where the units will advance to the target, but circumvent the intervening units.esci wrote:Since my kamikaze unit won't necessarily be at close range, is there any way to convince the AI that attacking the other units is very costly/not worth it?
You could also give the kamikaze units an attack of a new type that the target unit is incredibly vulnerable to, then change the attack type when the units move next to the target. (Or even when it attacks?)
Things like these are real tasks of exploration. It's often that much easier to accept the limitations of the AI and work your scenario to fit with what's given.
Try some Multiplayer Scenarios / Campaigns
I found a workable solution based on tsr's idea of making the other units "not there" during my kamikaze's turn. I'll post it here in case anyone else wants to do something similar.
The basic idea is to create a "dummy" side, allied with the kamikaze, for each real side. Then during the kamikaze's turn (here side 3), switch every unit except the target to its dummy side. The kamikaze unit then has no one to attack except the target, and with village_value=0 it won't be looking for villages, either, unless it's hurt.
The dummy side definitions look like
Then use the MODIFY_UNIT macro on the ScenarioWML page to switch all other units:
Then during side 4's turn, you switch everyone back. I should mention that this only works if the kamikaze is the last (non-dummy) side, as the switch back only executes if side 4 actually has some units. It also might cause some problems if side 2 was killed off before the kamikaze dies.
The price paid here is that the kamikaze is in no way restricted by ZOC or even the physical presence of units, since during its turn everyone is on its team. But that seems reasonable for an assassin-type unit, which is where this would usually apply.
The basic idea is to create a "dummy" side, allied with the kamikaze, for each real side. Then during the kamikaze's turn (here side 3), switch every unit except the target to its dummy side. The kamikaze unit then has no one to attack except the target, and with village_value=0 it won't be looking for villages, either, unless it's hurt.
The dummy side definitions look like
Code: Select all
# Dummy side for side 1
[side]
side=4
controller=ai
team_name=kamikazes
no_leader=yes
colour=1
[/side]
Code: Select all
[event]
name=side turn
first_time_only=no
[if]
[variable]
name=side_number
numerical_equals=3
[/variable]
[then]
# Switch everyone to dummy sides allied with side 3
{MODIFY_UNIT (side=1
[not]
description=George
[/not]) side 4}
{MODIFY_UNIT side=2 side 5}
[/then]
[/if]
[/event]
The price paid here is that the kamikaze is in no way restricted by ZOC or even the physical presence of units, since during its turn everyone is on its team. But that seems reasonable for an assassin-type unit, which is where this would usually apply.
No, seems totally unreasonable - moving through enemy units is against all known rules and the player should complain. Why don't you stone/unstone the units? That would make the enemy ignore them, too, I'd think.esci wrote:The price paid here is that the kamikaze is in no way restricted by ZOC or even the physical presence of units, since during its turn everyone is on its team. But that seems reasonable for an assassin-type unit, which is where this would usually apply.
Try some Multiplayer Scenarios / Campaigns
I'd say the AI should be changed so that we can set a target to be the only target the AI tries to attack. We could limit the target value= to a range of 0-100 for example, with 100 simply meaning that the AI doesn't consider anything else worth of attacking. Such a basic thing should be possible to do with the basic [ai] settings, IMO. The AI could perhaps still attack another unit if it ends it's movement near a hostile (while chasing the target) and is unable to attack the target.
I agree - have all AI parameters normalised. Better than that would be more documentation on how the AI works, how the different parameters interact (such as explaining that the AI always chooses a target in movement range over a target within a few turns' movement - no matter what the value).zookeeper wrote:We could limit the target value= to a range of 0-100 for example, with 100 simply meaning that the AI doesn't consider anything else worth of attacking. Such a basic thing should be possible to do with the basic [ai] settings, IMO.
Even with the side-changing or stoning technique described above, it only takes six level 0 units to completely screen off the leader and prevent the "assassins" from ever reaching their destination. Quick fixes don't necessarily work.

Try some Multiplayer Scenarios / Campaigns
ai and stoning
I tried stoning all units except my assassin/kamikaze unit and its target, but it didn't seem to work. The AI, rather oddly, still went after the tempting weaker units nearby, even though they were stoned. When it got there, it just sat there evidenly wanting to attack the stoned units but not being allowed to.Why don't you stone/unstone the units?
I'm guessing the AI decided on its strategy before the "side turn" event turning units to stone fired.