Pebbles in the Flood - Can hold out to infinity
Moderator: Forum Moderators
Forum rules
Before reporting issues in this section, you must read the following topic:
Before reporting issues in this section, you must read the following topic:
Pebbles in the Flood - Can hold out to infinity
Sir Gerrick is just 1 XP short of level up and no one wants to attack him, unless I attack first. Since this is The South Guard - Pebbles in the Flood scenario, where you need to hold out for as long as possible, I can do that to infinity.
OS: Debian 7 (Wheezy)
Wesnoth 1.10.3 - English (US) (from the Debian repo)
Turn 33:
Turn 104:
OS: Debian 7 (Wheezy)
Wesnoth 1.10.3 - English (US) (from the Debian repo)
Turn 33:
Turn 104:
- Attachments
-
- TSG-Pebbles_in_the_Flood-Auto-Save107.gz
- (119.78 KiB) Downloaded 325 times
-
- TSG-Pebbles_in_the_Flood-Auto-Save1.gz
- (31.9 KiB) Downloaded 346 times
Re: Pebbles in the Flood - Can hold out to infinity
This is normal ai behaviour, so not bug, scenario might need change.
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Pebbles in the Flood - Can hold out to infinity
This shouldn't be normal behavior, so I think that should change, not this scenario. You don't normally want to cause a unit to upgrade, but sometimes you have to.
In this scenario, there is no benefit to holding out longer than 22 turns, so go ahead and attack.
In this scenario, there is no benefit to holding out longer than 22 turns, so go ahead and attack.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: Pebbles in the Flood - Can hold out to infinity
I've already completed it.
I found it amusing that they didn't attack, so i was going "just one more turn".
I found it amusing that they didn't attack, so i was going "just one more turn".
Re: Pebbles in the Flood - Can hold out to infinity
I agree, in principle, but the devil is in the details. In fact, it is already like this. Sometimes the AI does attack a unit 1 XP from leveling. It's just that the condition is set in such a way (attack only if there's a chance, however small, to kill the enemy unit before it levels) that it is easily exploitable. For anything that involves a "usually you shouldn't but sometimes you should" decision, there will always be situations that can be exploited by a human player who's sufficiently experienced against the Wesnoth AI and it is up to the scenario designer to prevent that. In fact, when we rebalanced Son of the Black Eye, we did that in a number of scenarios, see for example here and here. But that is, of course, not a solution that the AI should use as a general rule.beetlenaut wrote:This shouldn't be normal behavior, so I think that should change, not this scenario. You don't normally want to cause a unit to upgrade, but sometimes you have to.
I don't want to say that this particular behavior should not be changed. In fact, I really think that it should (to the point that, when I am playing a campaign, I do not make use of this particular "feature"), I just don't know how. This is not as easy as it sounds, if you want to do in a way that does not result in something that is just as easily, or more so, exploitable in a different way.
And I have spent quite a bit of time thinking about this and playing around with it in my own AI experiments, so anybody who wants to convince me otherwise better come up with a very concrete suggestion rather than some generalisms.
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Pebbles in the Flood - Can hold out to infinity
I'm not sure I stand by my own previous statement any more, at least for the AI. Maybe the solution is just to make the AI prefer to attack units one or two points from upgrading. It seems like it should be a high-priority action so it happens early in the turn. I would also add these conditions, at least as a first guess: the AI must have at least one other unit that can reach the newly-upgraded one this turn; the AI shouldn't use poison, slows, magic, or marksman for this; and the AI must have at least four total units remaining. If the high-XP unit could possibly be killed, that attack should still take priority.
While this would be exploitable, I usually wouldn't want to exploit it.
While this would be exploitable, I usually wouldn't want to exploit it.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: Pebbles in the Flood - Can hold out to infinity
Thanks, that sounds like a good set of conditions to start out with. It's also reasonably easy to code that, or at least an approximation of it, as a Lua AI, so why don't I do that and people can test it for a little and send comments and suggestions for improvements.beetlenaut wrote:Maybe the solution is just to make the AI prefer to attack units one or two points from upgrading. It seems like it should be a high-priority action so it happens early in the turn. I would also add these conditions, at least as a first guess: the AI must have at least one other unit that can reach the newly-upgraded one this turn; the AI shouldn't use poison, slows, magic, or marksman for this; and the AI must have at least four total units remaining. If the high-XP unit could possibly be killed, that attack should still take priority.
Well, we can't add this to the default AI in the 1.11/1.12 branch anyway, since it would break the feature freeze and potentially unbalance some scenarios. But we could add a custom AI to Pebbles in the Flood, as that scenario is pretty much broken under the conditions reported by tomm.
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Pebbles in the Flood - Can hold out to infinity
Would it be a good idea to have some kind of failsafe? So for example, if attacking the unit that's about to level up is the only possible move, just attack it with anything after X turns.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Pebbles in the Flood - Can hold out to infinity
The simple attack micro AI does exactly that, but I suspect that switching to it by default might have some unintended consequences. Leaving it up to the scenario designer to use is probably a better option. If you are just talking about fixing Pebbles in the Flood though, that would do it.Pentarctagon wrote:just attack it with anything after X turns.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: Pebbles in the Flood - Can hold out to infinity
I put together a first attempt at an attack high XP enemy units AI that does pretty close to what beetlenaut suggested above. It still has some caveats (see below), but I think it is ready for some testing.
So what would be the best way to make this available to people for testing? I can easily turn this into a Micro AI, but I can only do that for Wesnoth 1.13 (because of the feature freeze in 1.12) and there's no 1.13 release out yet. In 1.12, it can be put into scenarios quite easily using the instructions below. Maybe that's good enough for now?
How it works
Known Problems
How to use the AI in a scenario (requires 1.11.16 or later)
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
Re: Pebbles in the Flood - Can hold out to infinity
Would it be practical to:mattsc wrote:The main problem at the moment is how to decide if a unit should be attacked. Let's say we have an enemy unit 2XP from leveling and there are L1 and L2 units that could attack it. The current code does not attack in that case, as the default AI might choose one of the L1s to attack. After that, the unit is 1XP from leveling, and the custom AI would kick in. Sounds great, in princple, but the problem is that the default AI does not always attack with an L1 (unless aggression=1 is set). I'm not entirely sure how to deal with this. The easiest would be always to force an attack if one of the units could cause a leveling of the enemy. But I am not sure that that is ideal. Suggestions welcome ...
- save the id of the 2XP-until-it-levels unit,
- then retain it as a filter for the next turn, so if the same unit is still 2XP-until-level,
- the custom AI condition #1 is overridden, and an attack is forced?
It won't help the AI be wiser within one turn, but it could possibly prevent (or at least complicate) multi-turn exploitation.
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
Re: Pebbles in the Flood - Can hold out to infinity
I always thought that when a "none solution is good" situation happens in AI behavior, it should be solved with some randomess in its behavior. That would at least solve "easy exploits from players" wich is at the end main problem, imho.mattsc wrote:The main problem at the moment is how to decide if a unit should be attacked.
edit: Or saying it in other way: If you reach conclusion any algorithm will have AI behaving stupidly in some cases, then dont let player predict those cases.
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
Re: Pebbles in the Flood - Can hold out to infinity
doofus-01: That is certainly feasible and might be a good fall-back option if we cannot come up with a reliable solution for the current turn.
tekelili: I read somewhere that the AI should not be basing its decisions on randomness, but in all the discussions I've had with other Wesnoth players, we've agreed that unpredictability is part of the fun. So, yes, that's also something to consider.
I'd still like to try if we can come up with some sort of reasoning for making a more informed decision first, and using your suggestions as a fall-back for when that does not work. In the case described, the default AI only attacks when it either has a chance for a kill, or when it can attack at a range at which the enemy cannot strike back. It should be (relatively) easy in most cases to figure out when that is the case and force the attack otherwise - maybe with some randomness built in and definitely attacking on the next turn if nothing happened this turn ...
Thanks for the suggestions! I'll keep thinking about this.
tekelili: I read somewhere that the AI should not be basing its decisions on randomness, but in all the discussions I've had with other Wesnoth players, we've agreed that unpredictability is part of the fun. So, yes, that's also something to consider.
I'd still like to try if we can come up with some sort of reasoning for making a more informed decision first, and using your suggestions as a fall-back for when that does not work. In the case described, the default AI only attacks when it either has a chance for a kill, or when it can attack at a range at which the enemy cannot strike back. It should be (relatively) easy in most cases to figure out when that is the case and force the attack otherwise - maybe with some randomness built in and definitely attacking on the next turn if nothing happened this turn ...
Thanks for the suggestions! I'll keep thinking about this.
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
Re: Pebbles in the Flood - Can hold out to infinity
I have been recently abusing a lot of almost leveled units over AI in World Conquest. In this campaign fronts are quite large, and I almost never got a "total lock". From what I most profited, was when I needed close front line in a spot with low defense like grass. As the AI often refused attack such unit, I could repeat several times trick, keeping front lines that otherwise could need a retreat. After evaluating how much would have damaged my army an early attack to level such units, and how could be that "understood" by aI, I reached to an idea it could worth try:
I never read BfW AI code, but I suspect damage/retaliation/chance to kill are the most important factors. If I am right with that, I propose AI candidate action to attack a unit with 0% chance to kill and would level up, becomes evaluated in function of dealing half expected damage (without heal from leveling considered) and double retaliation taken.
I reached to that conclusion, after realize in fact AI has to do 2 attacks to damage.
edit: Take 50%-200% values just as idea, AI could need different ones to evalaute well situation. What my idea means is that an intellegent AI should understand it is stupid If I were an AI I would think "those pesky humans minds almost ever outplay me, but from past experiences: they look to outplay me harder when I use to avoid attack units to level up than when I am prone to attack such units soon"
I never read BfW AI code, but I suspect damage/retaliation/chance to kill are the most important factors. If I am right with that, I propose AI candidate action to attack a unit with 0% chance to kill and would level up, becomes evaluated in function of dealing half expected damage (without heal from leveling considered) and double retaliation taken.
I reached to that conclusion, after realize in fact AI has to do 2 attacks to damage.
edit: Take 50%-200% values just as idea, AI could need different ones to evalaute well situation. What my idea means is that an intellegent AI should understand it is stupid If I were an AI I would think "those pesky humans minds almost ever outplay me, but from past experiences: they look to outplay me harder when I use to avoid attack units to level up than when I am prone to attack such units soon"
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
Re: Pebbles in the Flood - Can hold out to infinity
tekelili: you do indeed understand the main considerations of the AI for rating an attack, and deciding whether an attack is worth it. However, if I interpret what you are writing correctly, there's a problem with the practical implementation. If I understand you correctly, you are suggesting to evaluate an attack the way you suggest (which sounds perfectly reasonable), and then compare it to other attacks as evaluated by the standard combat candidate action.
And that comparison is the issue, because while we do have access to the result of the default evaluation function via ai.get_attacks(), we cannot pass a different (additional, whatever) function or parameter set to it without modifying the C++ code. So what we would need to do is write a Lua function that replicates the default combat rating function in Lua, so that we can substitute parts or inputs as needed. That's not really a problem per se, it just requires somebody to do so. In fact, I think I had most of that written at some point. I should search my computer sometime to see if I still have that code somewhere ...
All of that is, of course, only correct/applicable/whatever if I understand what you are saying correctly.
And that comparison is the issue, because while we do have access to the result of the default evaluation function via ai.get_attacks(), we cannot pass a different (additional, whatever) function or parameter set to it without modifying the C++ code. So what we would need to do is write a Lua function that replicates the default combat rating function in Lua, so that we can substitute parts or inputs as needed. That's not really a problem per se, it just requires somebody to do so. In fact, I think I had most of that written at some point. I should search my computer sometime to see if I still have that code somewhere ...
All of that is, of course, only correct/applicable/whatever if I understand what you are saying correctly.
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on