Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[modify_side][ai]ai_algorithm= doesn't work (GNA #16107) #1216

Closed
wesnoth-bugs opened this issue May 8, 2017 · 10 comments
Closed

[modify_side][ai]ai_algorithm= doesn't work (GNA #16107) #1216

wesnoth-bugs opened this issue May 8, 2017 · 10 comments
Assignees
Labels
AI Issues with the AI engine, including micro AIs. Bug Issues involving unexpected behavior.
Milestone

Comments

@wesnoth-bugs
Copy link

Original submission by anonymissimus on 2010-06-02

Changing default to idle_ai or vice versa has no effect. Both work when used in [side][ai], though. I think it was already present in 1.6. Not that big a problem though, since seemingly the same effect can be achieved with [modify_side]controller=null/ai which works.

cheers

(Reproduced on win xp)
Release: 1.8.0
Priority: 5 - Normal
Severity: 2 - Minor

@wesnoth-bugs wesnoth-bugs added AI Issues with the AI engine, including micro AIs. Bug Issues involving unexpected behavior. Windows OS-specific issues that apply to Microsoft Windows labels May 8, 2017
@wesnoth-bugs
Copy link
Author

Modified on 2011-12-13

anonymissimus wrote:

Still reproduces in trunk r52270.

@wesnoth-bugs
Copy link
Author

Modified on 2012-01-04

anonymissimus wrote:

testcode

+```+

[event]

  name=default

  first_time_only=no

  [modify_side]

  	side=2

  	[ai]

  		ai_algorithm=default_ai

  	[/ai]

  [/modify_side]

[/event]

[event]

  name=idle

  first_time_only=no

  [modify_side]

  	side=2

  	[ai]

  		ai_algorithm=idle_ai

  	[/ai]

  [/modify_side]

[/event]

-```-

@wesnoth-bugs
Copy link
Author

Modified on 2016-07-17

celticminstrel wrote:

There have been significant changes in this area recently, though I believe it has not fixed this bug yet. I'm posting mainly because the test code given below would need to be tweaked a little - to switch back to the default AI, you would need ai_algorithm=ai_default_rca rather than default_ai.

@wesnoth-bugs
Copy link
Author

Modified on 2016-07-17

celticminstrel wrote:

(The preceding comment applies to current master.)

@wesnoth-bugs
Copy link
Author

Modified on 2016-08-03

celticminstrel wrote:

Also note that [modify_side]switch_ai can already be used to achieve this behaviour, though it needs the path to the AI definition file (under data/ai/ais/ for default AI and data/ai/dev/ for idle AI) rather than the AI ID and is thus not as neat.

@Wedge009 Wedge009 removed the Windows OS-specific issues that apply to Microsoft Windows label May 9, 2017
@CelticMinstrel
Copy link
Member

Hmm, it's not easy to determine what this would do. Currently, the ai_algorithm key is essentially a shortcut, referencing one of the global [ai] tags. When a side's AI is initialized, that's resolved by essentially substituting in the contents of that global [ai] tag. To me, the most obvious effect of [modify_side][ai]ai_algorithm would be to strip out components that were brought in from the original AI and substitute in the components from the new AI, leaving any extra components untouched, but this is certainly harder than it sounds for a few reasons...

  1. Once ai_algorithm has been substituted, there is no remaining record of what algorithm was chosen. I think you can get the original algorithm by reading the side WML from somewhere, but what if you want to change it twice?
  2. The only way to determine which tags came from the algorithm is to parse the algorithm and then compare corresponding tags in detail, and I'm not sure if this is foolproof.
  3. Some global [ai] tags define aspects. All aspects with a given ID are merged together, making it even harder to figure out which aspects (or, more likely, facets) originally came from the algorithm and which were just brought in as default or added in the SideWML.

The only halfway method I can think of to make this work would be to actually reparse the [side][ai] but with the substituted ai_algorithm value. This however means that any prior changes made via [modify_side][ai] or via [modify_ai] (in an event) would be lost, which I think might surprise some people. Then again, it's probably not significantly more surprising than the "unit rebuilding" system, so maybe it's okay?

@CelticMinstrel CelticMinstrel added this to the 1.13.9 milestone May 13, 2017
@CelticMinstrel
Copy link
Member

@mattsc - Between what I describe above and just clearing the entire AI configuration and replacing it with the contents of [modify_side][ai], which seems better? Obviously the replacing would only happen if ai_algorithm is present; otherwise the configuration would be appended.

@mattsc
Copy link
Member

mattsc commented May 21, 2017

@CelticMinstrel - to me it seems to make sense that setting a new ai_algorithm would mean a full reset of everything else to default values (except anything given in the same [modify_side][ai] tag, as you say). Otherwise there will almost certainly be situations where you run into the kinds of problems you describe above, resulting in inconsistent behavior. Also, parameters (aspects etc.) might have different (or no) meaning in different AIs.

@CelticMinstrel
Copy link
Member

I'm not quite sure if that answers my question, so let me ask a different way... does it seem better to (1) use the contents of [modify_side][ai] as the full AI config, or (2) combine it with the contents of [side][ai]?

So, suppose you have the following scenario (just for illustration, values may be nonsensical):

[side]
  side=1
  type=Orcish Grunt
  [ai]
    ai_algorithm=experimental_ai
    aggression=2.5
    attack_depth=42
    [avoid]
      terrain=W*
    [/avoid]
  [/ai]
[/side]
[event]
  name=prestart
  [modify_side]
    [ai]
      ai_algorithm=formula_ai
      aggression=9
      caution=22
    [/ai]
  [/modify_side]
[/event]

Under (1), it would be equivalent to this:

[side]
  side=1
  type=Orcish Grunt
  [ai]
    ai_algorithm=formula_ai
    aggression=2.5
    caution=22
  [/ai]
[/side]

Under (2), that would be equivalent to this:

[side]
  side=1
  type=Orcish Grunt
  [ai]
    ai_algorithm=formula_ai
    aggression=2.5
    attack_depth=42
    caution=22
    [avoid]
      terrain=W*
    [/avoid]
  [/ai]
[/side]

@mattsc
Copy link
Member

mattsc commented May 21, 2017

In my mind I had answered that question, but I can see how it was not entirely clear outside my own head. ;) I'd go with (1), that's what I meant with "full reset".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI Issues with the AI engine, including micro AIs. Bug Issues involving unexpected behavior.
Projects
None yet
Development

No branches or pull requests

4 participants