• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.
Showing developer posts only. Show all posts in this thread.
I'm talking about "non-historical" AI of course)

Does AI react to neighbors foci selection and choices?

From my understanding. I could be wrong, but as far as I am aware AI is "Reactive" to each other's actions and decisions, and not just living in a silo. If it would live in a silo and make its decisions without regards for what countries around it or rivaling it would do, it wouldn't be a very competent AI)

(Imagine France not reacting to a "Around Maginot" focus selection by Germany).
Generally the way that you describe it is not what is eating up the CPU budget.
What takes time is computational heavy stuff that repeats often, like unit management, applying effects, Ai Actors, Supply etc. Things that has to run continuously. Thats not only for HoI, its for most games

As an example when you capitulate the USSR the game the game "hangs" for X seconds because its doing some heavy computations, but its not as bad because it only happens once.
 
Last edited:
  • 12
  • 9
  • 7Like
Reactions:
The engine being poorly optimized to use multiple cores is the real killer, maybe on HoI4 the game will run well on late-game for everyone, at moment it doesn't make a dent on CPUs even tho it really should.
Start the game with the launch option "-threads=1" and you will see how the game runs using only 1 thread. Every game from CK2 onwards has been multi-threaded from release.

Not everything is currently done in parallels because it is prohibitive without restructuring how certain things work, but that HoI does not use multiple threads isn't true because it does. If you go to the task manager and monitor logical cores and shut down HoI you will see that all cores drop in utilization. Thats not to say that there are things which can't be improved, there probably is, and its so with every program. HoI is more CPU bound than GPU bound because it has to do a lot of calculations.

What I am getting at is that its a bit more complex than say "just make it use multithreading". Its not a magic bullet that can be applied everywhere without other consequences :)

Also: https://en.wikipedia.org/wiki/Amdahl's_law
 
  • 12
  • 11Like
  • 11
Reactions:
Is EU4 multi-threaded too? I thought it is not, but your message argues otherwise.
98% sure it is. Just launch it in steam with -threads=1 in the launch options (right click on EU4 -> properties -> Launch options) and see if it chugs slower, probably notice it the most later in the game.

But then again, I want to reiterate that its not only multithreading being end all be all, its how its implemented, and not everything can be multithreaded properly because of certain factors. So its a bit more nuanced than "multithreading is not supported" or "multithreading is being implemented badly". I think some script executions are order dependent for example, which might be partially why some big mods are much slower than vanilla because they simply do more script executions. (not 100% sure so I can be wrong but if memory serves its something like that)

Not to say that there are no optimizations to gain, there probably are but you also hit a wall where the cost of doing optimization outweights the gain. Where we are generally in HoI I can't tell you because I dont have that expertise, but we do monitor performance before new releases. Anyway, I dont want to hijack OP's thread since he was giving his feedback but thats my 2 cents
 
  • 9Like
  • 6
Reactions:
Is it? May be AI uses LUA as well, does it not? I don't know the internals of HOI but adding RT byte-code interpreter just to load the defines is kind of an overshoot IMHO. And @CraniumMuppet mentioned external AI mods are using LUA extensively.
The AI code is in c++
Specific high level strategies are in the common folder and it uses the HoI scripting language, which is not related to LUA.
I meant that big mods usually have a lot of evaluations running, not necessarily AI (although that can be included) but also effects, targeted effects, on_actions, custom GUIs, variable manipulations etc. Usually the bigger the mod, the more custom stuff they implement, of course this eventually adds up to the overall performance degradation; somethings might be benign and some might really hog performance. Modders also all use the HoI scripting language and not LUA


But the scripting that CD's is not related to things like AI pathfinding, frontline management etc, which is what people commonly confuse the work that CD's do with that of programmers.
 
  • 4
  • 3Like
Reactions:
@CraniumMuppet But CDs do some high-level ai work, don't they? Meaning creating the ai_strategy_plan for new nationsm creating some ai_strategy for nudging production and the big part doing ai_weights for decision and events.

Those AI things are seperate from pathfinding and frontline management sure, but those are still AI things?
Correct.
It's a bit more nuanced. CDs can nudge the AI towards certain behaviors and there are some mods that does this really well (Expert AI for example).

Same goes for events, decisions, focuses etc. Most of what I see as criticism for the AI from the community more closely relates to lower level AI behavior such as Frontline management, prioritization of theaters, shuffling of troops etc which is not something CDs handle.

Usually these lower level issues in my experience does not always have clear simple answers on how to tackle since the AI doesn't have eyes in the same way as players do.

What I personally think most players issue with the AI is not necessarily that the AI is hard or easy, but rather that the AI sometimes inhibit behavior that we as humans see as "weird", so immersion is lost. Like "that's not something that a human would do" so it kinda breaks the illusion of playing against a real enemy

It's kinda the same when you exploit the AI in a similar way in Civ or Total Warhammer. Games in general struggle with AI and trying to have it behave as humans do.

Games like Dark Souls or the Witcher have a bit of an easier time because they are more isolated and can read player input. The enemies does not have to think far ahead, they just need to kill the player. AI in strategy games needs to think 2,3,4 steps ahead. I'm by no means any expert though, but it's generally a hard issue to fix because the fix isn't always clear.

A hard rule like "never cycle attack" can be implemented, but it's not always clear that it is not beneficial, like pinning down. Not that HoIs ai is without criticism, but a lot of suggestions about "stop the AI doing X" is usually not as simple a task at it may seem because its frought with what ifs and edge cases.

That's not to say that we should not seek to improve AI in games in general.
 
  • 6
  • 1Like
  • 1
Reactions: