Simspeed: What performance improvements could be ported from LOUD MOD?

Also an old topic. Last result was "lots of work, won't happen". How exactly was this determined? I looked at the LOUD lua code, and while yes, the changes are significant (especially the weird naming of functions of LOUD) porting it should not be impossible.

Let me quote Uvesos summary from our developer chat here (the question pops up every few months):

We are already working with Sprouto (the maker of LOUD) together for month.
He joined our AI-Development Discord and is sharing his knowledge with us.

The changes in LOUD compared to FAF are insane huge. Some examples:
LOUD is using special maps to increase the gamespeed (flat maps to reduce the c-engine pathing)
It has reduced graphic effects on units. (removed blinking lights, optimized build beams etc)
Also sounds like ambient sound on units are removed.

Many people think that's all what it needs to be fast, but the real speed changes are inside the code.
In Loud a Air unit class does not have any functions from land or navy units.
Every lua file does first localize any global used function like WaitTicks(), table.getn() etc. to increase the speed.
Almost every function is optimized/rewritten/moved to a different location.

But FAF itself has also some functions that makes FAF slower than the original game.
The veterancy system (callbacks to every unit that is involved in a fight)
Shield damage overspill (search for overlapping shilds to transfer damage to nearby shields)
Reclaim (unit.lua function SetRebuildProgress is cloning every wreck on the whole map in some cases)
And many other stuff that we have in FAf to prevent cheating or fixing c-engine behavior.

So there is no compatibility at all.
It would be easier to implement FAF into LOUD.

Asking if we can make LOUD as mod for FAF is the same than asking if we can make SupCom2 as mod for FAF.

"Nerds have a really complicated relationship with change: Change is awesome when WE'RE the ones doing it. As soon as change is coming from outside of us it becomes untrustworthy and it threatens what we think of is the familiar."
– Benno Rice

Such significant changes would break most of the mods. And we get enough shit for breaking one favourite mod.

But this does not mean, we are not optimizing the AI or gamespeed.
These are the latest AI patches.
Read the patchnotes to see whats already done:

AI Patch V1:
https://github.com/FAForever/fa/pull/2468
AI Patch V2:
https://github.com/FAForever/fa/pull/2566
AI Patch V3:
https://github.com/FAForever/fa/pull/2660
AI Patch V4:
https://github.com/FAForever/fa/pull/2734
AI Patch V5:
https://github.com/FAForever/fa/pull/2802
AI Patch V6: (AI pathfinding "A*(Star) search algorithm".)
https://github.com/FAForever/fa/pull/2915
Fix for AI Base templates
https://github.com/FAForever/fa/pull/2918
AI Patch V8:
https://github.com/FAForever/fa/pull/3083

(Patch V8 is only available on the FAF develop version.)

The terrain thing is an unfortunate pitfall of fa’s engine. Having terrain elevation and small bumps is something I think we cannot compromise on in light of the recent mapping work of arts the faf community has been producing.

That being said: the map generator generates maps which (minus the ramps which should account for very little) should equal a fully flat map’s performance.

Removing unit ambient sounds and blinking lights and optimizing the build beams is something we could totally do. (Faf players mostly don’t care about those details.)

I don’t know about the no function calls from naval or land units on air units, I don’t exactly understand what is being done there. I imagine that it might remove certain unit interactions which is a no-go in terms of preserving faf gameplay. If these are useless calls in terms of preserving our gameplay then yeah we can do away with them too.

The function relocalization and optimisation shtick sounds like something we can duplicate.

The wreaks thing is, as I understand it the mechanic that allows us to resume build progress on top of a wreak? Isn’t that vanilla in fa? They implemented this in supcom2, I don’t think faf had had any influence on supcom2.

The veterancy system was experienced by the faf community as a most welcome balance change but I didn’t know the performance cost was so high. Perhaps a full revamp or at least an optimisation pass is in order.

As for the shields mechanic, I consider every compute cycle spent on it, well spent.
It stays.

And obviously same goes for the anti cheat stuff.

All in all I feel like we can bridge a lot of the performance gap on a non ai level and of course on the ai level, well faf-hosted ais may not be as performant as LOUD ai (or maybe they are, I wouldn’t know how to isolate that metric) but in my experience, having beat both a 1x LOUD and having gone up to the maximum, 2x and beat it multiple times, whereas I can’t beat a 2x uveso to save my life. And keep in mind that in LOUD on 2x, the ai’s t1 tank will win against your t3 tank. Just to give you a metric by how much loud ai cheats unit stats.

Safe to say the tradeoff in performance, whatever it is, has paid off in terms of ai smarts on faf.

I'd like to dispel some of the popular myths about LOUD - and then discuss some of what's been mentioned here.

Firstly, while we have indeed 'flattened' some starting areas on maps, to permit LOUD to use his preset base layouts, we have not, in general, done any flattening on maps as a whole. We have certainly upscaled some smaller maps to 20k and 40k, and that has certainly smoothed the inclines in some places, but it was not a goal to 'flatten' any maps - rather - knowing what we know about AI, and map markers, we've remarked those maps we distribute thru LOUD to take advantage of that knowledge, and as such, they perform better, and the AI comprehends them so.

With regards to graphics and sound - yes - we have indeed suppressed many very minor things, and, in the past, we had entirely turned off certain effects such as contrails, or excessive particle effects, but, over the years, as we've found other places to gain, we've brought almost all of them back. As for sounds, yes - a great many ambient sounds have been turned off, but this is not for performance, but it pays dividends in memory consumption - which indirectly aids in performance, but moreso in LOUD's ability to support games with higher unit counts. In fact, LOUD has built a dynamic system which leaves all the effects functions in play until the SIM drops below 0, at which point they begin turning down or off entirely if the speed drops too low.

A great deal of LOUD's performance comes from an understanding of memory management, garbage collection, and methods to reduce both, and this has resulted in the rewriting of many core functions - and as noted above - 'declassing' which, as applied to what was noted above, means that Air units don't carry around baggage from other unit classes.

I'm not sure what the 'wrecks' comment is all about - LOUD has had naval wreckage for a long time, but again, similar to the effects, we decided on a dynamic system which will remove wrecks that are not reclaimed over time, resulting in dramatically improved entity count and significantly better memory management over the course of long games.

Now - all of this work in LOUD is pointed specifically at the long and very long games, on very large maps, with very high unit counts, and as such, the AI is not aimed at the FAF demographic. That it doesn't show well on 5k and 10k maps is intentional, and certain 'set piece' 20k maps, like Setons, offer limited tactical options that can make it rather easy to defeat a 1.0x LOUD, but that is why we continue to work on it - and having someone to converse with AI issues, after essentially working alone for most of the last decade is, at last, refreshing.

Uveso has advanced the AI for FAF a long way from it's crippled Sorian state, and along the way, crossed many of the same bridges as we had to cross in LOUD, especially in core areas like understanding the shortcomings of the default functions that support the AI, and taking advantage of some of the unused features available. I'm sure there will be more to come, and the opportunities to increase the performance (if it's even a concern in most FAF games) is there for the taking.

As an addition: I for one would not recommend any FAF focus on AI. AI I would at least assume is a neglectable use case in FAF. The vast majority of us would care about increased performance in multiplayer.

Half of all FAF games are launched with a single team. This includes coop, sandbox, etc, but it’s fair to say a significant part of the client’s userbase is here purely for pve.

That of course doesn’t mean we would do balance changes in consideration of ai games or sacrifice pvp aspects for pve, but the userbase is still there.

I would happily agree with FTX, and i dont believe we should be balancing the game for PvE though maybe a differently balanced gamemode 🤔 because of a AI Developer, its honestly really hard to do real ai improvements and work and etc with the way balance is right now.

To simply describe balance issues, bascially the balance is forcing us as AI Developers to develop our AI in a very specific way that i keep in mind most of dont like in reality and simply put the AI cant keep up in the way the balance is right now. The game is just too fast especially mid game and late game and even early game. Eco in FAF scales too quickly, The Meta is too strong and the balance is restrictive on what you can actually do in the game. I mean like seriously you do it the meta way or the highway. Thats how FAF balance has always been.

I have played LOUD, and ill say it here and right now, that the balance on LOUD is a lot more fun because i have choice and that choice lets me play the game more happily and more creatively. Thats what should be important and fun. I feel like we stress that we are a pvp community so much that we forgot
Quoted From FTX "That half the faf games are launched with a single team" which means in reality we look over 50% of faf in favor of the pvp community when we should be balancing ourselves truly.

Developer for LOUD Project | https://discord.gg/DfWXMg9
AI Development FAF Discord | https://discord.gg/ChRfhB3
AI Developer for FAF

Community Manager for FAF
Member of the FAF Association
FAF Developer