Message to Devs on AI

Please post here for questions and discussion about modding for Strategic Command.
User avatar
Lothos
Posts: 1246
Joined: Tue May 23, 2006 8:22 pm

Message to Devs on AI

Post by Lothos »

To whom it may concern

Some of you may know me from my Hearts of Iron 2 and Hearts of Iron 3 days. Worked heavily on the official AI for both of those games and created a mod called Total Realism Project (TRP).

I've gotten the modding itch a bit again and started looking at both World at War and War in Europe and am heavily creating a modification for the War in Europe version.

If you know my work you know that AI is what I focus on mainly. My proudest work was the last set of LUA files I created for Hearts of Iron 3 which was the first ever design that had a dynamic Espionage, Diplomatic, Research and Production AI that was not hard coded.

So, the reason why I am creating this thread

The purpose of this thread is to put my thoughts in as I discover items and give you my thoughts and recommended changes, what you do with my suggestions is totally up to you. I just hope that with my significant background you would take a few minutes to read and give it some thought.

One last note, At that time of this post I have a total of 1,112 hours playing your game.

Suggestions

#1 - Build Ratio with Air/Land/Sea then Ratio within each group
#2 - NOT_FRIENDLY_POSITION - to be used same way as FRIENDLY_POSITION in all AI scripts that have FRIENDLY_POSITION, support multiple entries using an AND clause.
#3 - MP Collection Per Turn Trigger for all AI events if its MP > XXX
#4 - VARIABLE_CONDITION allow a dummy value to be assigned their are many areas that their is no need for this and you are forced to then create identical events for Axis, Allies, War and Peace.
#5 - TACTICAL_CONDITION allow a dummy event for this as most countries you are forced to put their capital as the main point and then (for example) if used for production you loose your capital they would stop producing unless you can guess in your scripts where they are going. I was able to use a work around and use province 0,2 which has a town in Canada but it should not require something like this.
#6 - LINK= - AI Events, recommend support multiple Links with an OR clause for each of them so if any of the conditions are true then it fires. This may be a good feature to also add to other places to. It would help cut down on the duplicate events to handle conditions such as the winter war.
#7 - You can only have one convoy between two countries. For example if you want to have a convoy from Glasgow to Murmansk and another one from Glasgow to Archangelsk. This would help simulate how Murmansk was a small port but open all year and Archangelsk was the major port and during the summer months the USSR would get way more supplies. I tried to do this and it would not work. Best I could do was have UK ship to one port and USA to the other.
#8 - Coastal Guns can be placed in any hex using the UNIT.txt file but no other land unit can do that. Request that we be allowed to place units in any hex instead of always being limited to a resource hex. This would allow (for example) the direct placement of Finland's troops in specific positions based on weather the winter war happened or not. Right now they get placed around city hexes that are a bit out of place on where you want them.

Known Bugs
#1 - (Confirmed by Devs) - Vichy France formation (as a major power, play with fog of war) ,toggle No Fog On/Off or switch Sides causes a crash.
-- Work Around Solution, wait one turn and it will work again.

#2 - Fortification.txt events accept multiple #GOAL_POSITION= with no crash or error. However when the AI completes the first #GOAL_POSITION= listed in the event it will ignore the rest. Suggestion is to support multiple #GOAL_POSITION= within the same event and only shut it down once all the #GOAL_POSITION= have forts or the rest of the trigger is no longer valid. This would help cut down the amount of events within the file as many can be grouped together.

#3 - (Devs Thinking About it) - - Simultaneous Turns - Weather keeps alternating even though the date is the same for both sides. When turns are simultaneous the weather should not change until the calendar date changes

#4 - (Confirmed by Devs) - Neutral major power AI wont transport troops into a minor country it controls.

#5 - (Removed)

#6 - AI does not know how to use Naval Bombers. It consistently tries to use it for Building up offensives and near land forces (in land) rather than using it near a coast or an island to attack enemy ships or to protect its convoy routes.

#7 - (Removed)

#8 - AI does not upgrade air units that are locked in place (guard command) and has a mission it can run. I have locked a Strategic bomber in the UK and it bombs Germany constantly but it has not been upgraded in the 2 years (in my sim) it has been their. I have ran several sims and it never gets upgraded (even though it can).

#9 - Discovered this, I tried to adjust the weather zones to see if it could be fixed and it does not. If a tile that has a little land in it, and you hover with the mouse and it says Sea for it, the weather is always clear. I think this is in part because the weather zones that Matrix created are broken down into either Land or Sea (never combined) and even though the tile is a Sea tile the engine gets confused because it has a little land.

#10 - Garrison AI can't be assigned to X coordinate of 0 (thread provided with screenshot)

#11 - Surrendered Major powers that are collecting MP through minors can not research
Last edited by Lothos on Sun May 15, 2022 10:29 am, edited 27 times in total.
User avatar
Lothos
Posts: 1246
Joined: Tue May 23, 2006 8:22 pm

Re: Message to Devs on AI

Post by Lothos »

Suggestion #1 (please use this as a reference if you choose to reply)

Production AI suggestion

Working on enhancing the AI and I noticed that the design is a percent based system with a max amount to produce.

Side Effects from this design
- You run the danger of certain areas getting to much over another with massive imbalances

Suggestion
- Switch to a ratio based system with an acceptable deviation so have for example 5 infantry per 1 armor and 1 HQ etc....

This would solve the problem of (for example) all the armor for an AI country being wiped out and the AI not rebuilding it. Or the US fleet has all of its carriers destroyed and not rebuilding them right away.

The ratio design that I found best to work was a two layer
- Top layer ratio of Air vs Land vs Sea high level ratio
- Sub ratio layer with each of the top layers for the unit types
User avatar
Elessar2
Posts: 1440
Joined: Wed Nov 30, 2016 12:35 am

Re: Message to Devs on AI

Post by Elessar2 »

I've noted issues with the Build scripts too. The devs insisted that each unit type gets a fair shot at being "chosen", but I'm not so sure.

The problem I ran into (which is one reason I ceased work on any AI scripts for my WitP mod) is that ships tended to not get built until pretty much every other unit has been built, with either the probabilities made too low, all the ship script lines at the bottom (read last?) or the AI running out of money (yes I know about the Skip Funds Check toggle). The US finally got a ton of ships into the queue in a World run-thru I did a couple of years ago, due in '44 & '45, but by then the US Navy had basically ceased to exist.

The only workaround I could come up with was, like with certain vanilla Research scripts, put in some which periodically ensured only ships could be built.
User avatar
Lothos
Posts: 1246
Joined: Tue May 23, 2006 8:22 pm

Re: Message to Devs on AI

Post by Lothos »

This is good to know

I been playing heavily with the AI to understand how it works. The AI seems to have a priority in the following order

- Reinforce (no idea how it chooses this)
- Purchase Units (in the order listed in the files)
- Research (in the order listed in the files)

Problem is that most of the time their is almost nothing left to use for research.

Did you discover the same issue?
User avatar
steevodeevo
Posts: 173
Joined: Wed Dec 28, 2005 10:12 am
Contact:

Re: Message to Devs on AI

Post by steevodeevo »

Interesting stuff so far.

Question? why would the AI need to research? I would imagine, especially in pre-made scenarios &campaigns that the unit upgrades and new models for the AI are 'hard coded' and set against a timer for unlocking?

This could be a completely idiotic observation, apologies if so.
User avatar
Lothos
Posts: 1246
Joined: Tue May 23, 2006 8:22 pm

Re: Message to Devs on AI

Post by Lothos »

When playing the long scenarios for example 1939 till end of game research is necessary and the AI is almost always behind in this area.

What I discovered looking at some of the mods made for the game it seems like most people (to help compensate for the AI) would give free units. My favorite mod is Fall Weis and I been using that as my baseline for the redesign (with the original moders permission of course).

I am still in the process of experimenting what the AI can and can't do well. So far the buying of units is not to bad but research it is simply horrible because of the lack of MP. Their is an ability to make the AI do research and not have to pay for it using SKIP_FUNDS_CHECK

My big question (which I can't figure out the answer so far) is when this SKIP_FUNDS_CHECK is set to true. And lets say the AI has 50 MP but the tech cost 110. Does the AI use the 50 it has left or is the tech completely free.
User avatar
Lothos
Posts: 1246
Joined: Tue May 23, 2006 8:22 pm

Re: Message to Devs on AI

Post by Lothos »

Suggestion #2

Please add a NOT_FRIENDLY_POSITION to the parameters to be used in the AI files. Reason for this is that their is no good way right now to tell the AI which ports are save to transport to or not. Yes their is the CANCEL command but that only looks for units in the area. What if the area is controlled by the enemy but no units are present in it. Their is no way to tell the AI to shut down a script that is designed (for example) to transport troops to TOBRUK but to shut that down if it is taken and to start transporting to Benghazi instead.

The cancel command (unless it can act as a NOT_FRIENDLY_POSITION) with ought the need to have an enemy unit in the hex is not really an option.
User avatar
BillRunacre
Posts: 6516
Joined: Mon Jul 22, 2013 2:57 pm
Contact:

Re: Message to Devs on AI

Post by BillRunacre »

steevodeevo wrote: Fri Apr 01, 2022 11:03 am Interesting stuff so far.

Question? why would the AI need to research? I would imagine, especially in pre-made scenarios &campaigns that the unit upgrades and new models for the AI are 'hard coded' and set against a timer for unlocking?

This could be a completely idiotic observation, apologies if so.
The AI has to carry out its research in the same way as everyone else, this keeps things a bit unpredictable and is also fair.
Follow us on Twitter: https://twitter.com/FurySoftware

We're also on Facebook! https://www.facebook.com/FurySoftware/
User avatar
BillRunacre
Posts: 6516
Joined: Mon Jul 22, 2013 2:57 pm
Contact:

Re: Message to Devs on AI

Post by BillRunacre »

Thanks for the suggestions so far Lothos, if you have any more please do post them! :)
Follow us on Twitter: https://twitter.com/FurySoftware

We're also on Facebook! https://www.facebook.com/FurySoftware/
User avatar
Lothos
Posts: 1246
Joined: Tue May 23, 2006 8:22 pm

Re: Message to Devs on AI

Post by Lothos »

Suggestion #3

The MP Collection per check would help solve the issue of adjusting the research and production of the AI based on the size of their economy. Since MP is their economy in this game it is a flat ability.

This would allow you to adjust the build AI based on if they are loosing or winning. So if Germany is winning the war you would want to expand their build and research to include more expensive items such as ships and carriers. But if they are loosing the war you want them to focus on land units, maybe only infantry if their economy is in complete shambles.

Yes, it could be argued that (in regards to production) the current system with percentages handles that because it should theoretically fire before reaching the more expensive items before its MP collection ever gets that high.

HOWEVER, I would counter argue that it is still mathematically possible that the situation can happen.

Now in regards to research, their is no reason to research ships and naval if you are getting destroyed. You would want to focus more on land.

One last note, having a MP check is way easier than putting in checks to see if you control specific hexes and adjusting your research/production based on that. Doing it based on MP (your economy) makes it so it can handle unforeseen circumstances in case the AI goes nutz in an unforeseen direction (this was very common in the Hearts of Iron series which is why I designed the AI in the LUA that way).
User avatar
Lothos
Posts: 1246
Joined: Tue May 23, 2006 8:22 pm

Re: Message to Devs on AI

Post by Lothos »

Updated main post with bug #1

Make Vichy a major power and when its created that first time if you turn off Fog of War the game will crash. Happens 100% of the time.
User avatar
Lothos
Posts: 1246
Joined: Tue May 23, 2006 8:22 pm

Re: Message to Devs on AI

Post by Lothos »

Updated Main Post with Bug #2

#2 Fortification.txt events accept multiple #GOAL_POSITION= with no crash or error. However when the AI completes the first #GOAL_POSITION= listed in the event it will ignore the rest. Suggestion is to support multiple #GOAL_POSITION= within the same event and only shut it down once all the #GOAL_POSITION= have forts or the rest of the trigger is no longer valid. This would help cut down the amount of events within the file as many can be grouped together.
User avatar
Hubert Cater
Posts: 5986
Joined: Mon Jul 22, 2013 11:42 am
Contact:

Re: Message to Devs on AI

Post by Hubert Cater »

Elessar2 wrote: Thu Mar 31, 2022 10:58 pm I've noted issues with the Build scripts too. The devs insisted that each unit type gets a fair shot at being "chosen", but I'm not so sure.
Hey Elessar, I can confirm this is still accurate as the game does not prioritize any unit, e.g. the unit list is indeed randomized to ensure this.

An easy way to test this is in a test campaign set very low costs for your unit purchases and see what it does etc.
Last edited by Hubert Cater on Wed Apr 06, 2022 8:44 pm, edited 1 time in total.
User avatar
Hubert Cater
Posts: 5986
Joined: Mon Jul 22, 2013 11:42 am
Contact:

Re: Message to Devs on AI

Post by Hubert Cater »

Lothos wrote: Mon Apr 04, 2022 11:13 pm Updated main post with bug #1

Make Vichy a major power and when its created that first time if you turn off Fog of War the game will crash. Happens 100% of the time.
Thanks for the report, do you happen to have a saved turn where this is repeatable? e.g. a saved turn right before Vichy is created and then where we can turn off Fog of War?

If this is from a mod, could you send the modified campaign our way as well?

If the files are large, please feel free to send via WeTransfer as it is a free file transfer service.

Please send to support@furysoftware.com

Thanks!
Hubert
User avatar
Lothos
Posts: 1246
Joined: Tue May 23, 2006 8:22 pm

Re: Message to Devs on AI

Post by Lothos »

Hubert Cater wrote: Wed Apr 06, 2022 8:42 pm
Lothos wrote: Mon Apr 04, 2022 11:13 pm Updated main post with bug #1

Make Vichy a major power and when its created that first time if you turn off Fog of War the game will crash. Happens 100% of the time.
Thanks for the report, do you happen to have a saved turn where this is repeatable? e.g. a saved turn right before Vichy is created and then where we can turn off Fog of War?

If this is from a mod, could you send the modified campaign our way as well?

If the files are large, please feel free to send via WeTransfer as it is a free file transfer service.

Please send to support@furysoftware.com

Thanks!
Hubert
It is from the MOD I am working on but it is pretty easy to duplicate. Go into the editor, make Vichy a major power. Then play the game as normal with Fog of War on. The same turn Vichy is formed if you try and turn off Fog of War the game will crash. It happens 100% of the time even with loading from a save.

Did you want me to send you the current state the mod is in plus a saved game or just a saved game? How do I address the email?
User avatar
Lothos
Posts: 1246
Joined: Tue May 23, 2006 8:22 pm

Re: Message to Devs on AI

Post by Lothos »

Hubert Cater wrote: Wed Apr 06, 2022 8:42 pm
Lothos wrote: Mon Apr 04, 2022 11:13 pm Updated main post with bug #1

Make Vichy a major power and when its created that first time if you turn off Fog of War the game will crash. Happens 100% of the time.
Thanks for the report, do you happen to have a saved turn where this is repeatable? e.g. a saved turn right before Vichy is created and then where we can turn off Fog of War?

If this is from a mod, could you send the modified campaign our way as well?

If the files are large, please feel free to send via WeTransfer as it is a free file transfer service.

Please send to support@furysoftware.com

Thanks!
Hubert
Looking at the error message and reviewing the top bar moral panel I think the error is that Vichy was created (and its a major power) but it takes one turn for it to draw its moral on the top panel.

So this only happens on the initial turn, after that the moral panel is updated. (Screenshot below)
Attachments
OziVb6eZPN.jpg
OziVb6eZPN.jpg (859.44 KiB) Viewed 932 times
User avatar
Lothos
Posts: 1246
Joined: Tue May 23, 2006 8:22 pm

Re: Message to Devs on AI

Post by Lothos »

Bug #3 - Simultaneous Turns - Weather keeps alternating even though the date is the same for both sides. When turns are simultaneous the weather should not change until the calendar date changes.

So what happens is one side can get clear weather and the other side can get a torrential rain and both sides are playing on the same exact date.
User avatar
Elessar2
Posts: 1440
Joined: Wed Nov 30, 2016 12:35 am

Re: Message to Devs on AI

Post by Elessar2 »

Hubert Cater wrote: Wed Apr 06, 2022 8:38 pm
Elessar2 wrote: Thu Mar 31, 2022 10:58 pm I've noted issues with the Build scripts too. The devs insisted that each unit type gets a fair shot at being "chosen", but I'm not so sure.
Hey Elessar, I can confirm this is still accurate as the game does not prioritize any unit, e.g. the unit list is indeed randomized to ensure this.

An easy way to test this is in a test campaign set very low costs for your unit purchases and see what it does etc.
OK, gotcha. Then that means the list is randomized, THEN read in the random order from start to end?

If so, that's good to know and will affect what I do with the scripts in question.
User avatar
Hubert Cater
Posts: 5986
Joined: Mon Jul 22, 2013 11:42 am
Contact:

Re: Message to Devs on AI

Post by Hubert Cater »

Lothos wrote: Wed Apr 06, 2022 9:35 pm So this only happens on the initial turn, after that the moral panel is updated. (Screenshot below)
Thanks this is helpful
User avatar
Hubert Cater
Posts: 5986
Joined: Mon Jul 22, 2013 11:42 am
Contact:

Re: Message to Devs on AI

Post by Hubert Cater »

Elessar2 wrote: Wed Apr 06, 2022 11:56 pm
OK, gotcha. Then that means the list is randomized, THEN read in the random order from start to end?

If so, that's good to know and will affect what I do with the scripts in question.
Correct the unit list is randomized each time it reads in a purchase event, e.g. a unique random order for each event (and each time through on each turn), and then it reads in that list from start to end.
Post Reply

Return to “Scenario Design and Modding”