Making the AI faster
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.
- Nyanyanyan
- Posts: 73
- Joined: May 11th, 2018, 10:40 pm
Making the AI faster
Playing very big multiplayer maps with a lot of units will make even the Default AI go excruciatingly slow, so I was wondering if it was possible to make the AI go faster in any way, even at the cost of worse performance, strategically.
I am not very experienced in AI WML, so I have no idea if this is possible or how I could archive it.
Any help is appreciated.
I am not very experienced in AI WML, so I have no idea if this is possible or how I could archive it.
Any help is appreciated.
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.
Re: Making the AI faster
I recently posted an AI question to the forum, so I've been reading about AI behavior. I can't answer your question with a code example, but I do know that the answer to your question is yes, the AI can go faster.
From the Wesnoth Wiki:
From the Wesnoth Wiki:
Follow the link and check it out. I think you need to use a "micro ai."https://wiki.wesnoth.org/Micro_AIs (ai_type=fast_ai)
(Version 1.13.0 and later only)
This AI is meant as a fall-back AI for scenarios where there are so many units that attacks and moves done by the default AI are slow with long delays before each move.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
- Nyanyanyan
- Posts: 73
- Joined: May 11th, 2018, 10:40 pm
Re: Making the AI faster
I tried applying the fast_ai micro ai to every side in an AI vs AI game but they're still incredibly slow on big maps.
Here's my code.
Did I do something wrong?
Here's my code.
Code: Select all
[modification]
id=Fast AI Enabler
name=_"Fast AI Enabler"
description=_"Enables the Fast Micro AI for MP matches, making the AI play worse but faster (who would have guessed?)."
require_modification=yes
[event]
id=fast_ai_enabler
name=prestart
first_time_only=no
[store_side]
[filter]
[/filter]
variable=fast_ai_enabler_variable
[/store_side]
{FOREACH fast_ai_enabler_variable i}
[micro_ai]
side=$fast_ai_enabler_variable.side
ai_type=fast_ai
action=add
leader_attack_max_units=6
[/micro_ai]
{NEXT i}
{CLEAR_VARIABLE fast_ai_enabler_variable}
[/event]
[/modification]
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.
Re: Making the AI faster
Do you use "Accelerated speed" in preferences? It can speed up animations and save you lots of time.
- Pentarctagon
- Project Manager
- Posts: 5565
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Making the AI faster
There's also the Skip AI Moves preference if the issue is the time the movements/animations are taking.
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
- Nyanyanyan
- Posts: 73
- Joined: May 11th, 2018, 10:40 pm
Re: Making the AI faster
No, those aren't the issue. It's the actual time the AI takes to make decision.
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.
Re: Making the AI faster
[store_side] expects a side filter, without using a [filter_side] tag - so, just what one put's usually into a [filte_side] tag, but in a [store_side] tag. Btw, [filter] is always a unit filter.
The [filter] tag is not a valid tag inside a side filter. I'm not sure what the engine does in this case, but maybe it lead to your side filter evaluating to false, and thus the micro ai not being applied. If you don't specify anything for filtering, your code will match all sides. Try your code without these two lines again. (and maybe use [foreach] instead of {FOREACH})
When you use the
There's also another way to speed up the AI. The normal AI has a paramter
You can also check with inspect if it was applied correctly.
The [filter] tag is not a valid tag inside a side filter. I'm not sure what the engine does in this case, but maybe it lead to your side filter evaluating to false, and thus the micro ai not being applied. If you don't specify anything for filtering, your code will match all sides. Try your code without these two lines again. (and maybe use [foreach] instead of {FOREACH})
When you use the
:inspect
command, you can also see information about an sides AI. Most micro ais will add a new Candidate Action into the list shown under "stages" - with this micro AI one I'm not sure.There's also another way to speed up the AI. The normal AI has a paramter
simple_targeting
.You can also check with inspect if it was applied correctly.
Try out the dark board theme.
- Nyanyanyan
- Posts: 73
- Joined: May 11th, 2018, 10:40 pm
Re: Making the AI faster
I did that, but it didn't make the game any faster and sadly I couldn't see anything in the inspection windows that would show me that fast ai is enabled.Shiki wrote: ↑October 15th, 2020, 4:44 pm [store_side] expects a side filter, without using a [filter_side] tag - so, just what one put's usually into a [filte_side] tag, but in a [store_side] tag. Btw, [filter] is always a unit filter.
The [filter] tag is not a valid tag inside a side filter. I'm not sure what the engine does in this case, but maybe it lead to your side filter evaluating to false, and thus the micro ai not being applied. If you don't specify anything for filtering, your code will match all sides. Try your code without these two lines again. (and maybe use [foreach] instead of {FOREACH})
When you use the:inspect
command, you can also see information about an sides AI. Most micro ais will add a new Candidate Action into the list shown under "stages" - with this micro AI one I'm not sure.
There's also another way to speed up the AI. The normal AI has a paramtersimple_targeting
.
You can also check with inspect if it was applied correctly.
I tried simplifying the code even more to prevent any mistakes but I'm not sure if it works now. At least the map still isn't playable.
Code: Select all
[modification]
id=Fast AI Enabler
name=_"Fast AI Enabler"
description=_"Enables the Fast Micro AI for MP matches, making the AI play worse but faster (who would have guessed?)."
require_modification=yes
[event]
id=fast_ai_enabler
name=side turn 1
first_time_only=no
[micro_ai]
side=$side_number
ai_type=fast_ai
action=add
[/micro_ai]
[print]
text="Fast AI Enabled"
size=300
duration=3000
[/print]
[/event]
[/modification]
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.
Re: Making the AI faster
If the Fast MAI is enabled, you should see the following in the AI Component Structure inspect dialog for the side (scroll down to the bottom). Note the three candidate actions starting with "mai_fast_".
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