1. AI War 2
  2. News

AI War 2 News

Beta 3.752 Pathfinding Efficiency

New build! https://wiki.arcengames.com/index.php?title=AI_War_2:The_Great_Refactor#Beta_3.752_Pathfinding_Efficiency

In the past, whenever I've talked about the efficiency of pathfinding, I've universally been speaking about CPU usage or "number of paths calculated per second" or something along those lines. This time, I'm talking about RAM efficiency -- how much RAM is used, how it gets reused, and so on. We do a lot of pathfinding on a lot of threads for a lot of reasons, and that data can be absolutely enormous if we're caching it for too long. Similarly, in the past, we've had major CPU load caused by not caching it enough.

What I've done at this point is kept the caching to the level of "this current slice of time for this thread," whatever that means. Sometimes it means "this frame" when we're talking about the UI. A lot more frequently, it means "this simulation step," when it's something for the simulation itself (aka, for 100ms). Even vastly more frequently, it means "this run of long-range-planning operation," which is something that happens intermittently for each faction every few seconds and lasting for usually part of a second, but up to several seconds if need be.

The TLDR is that the amount of CPU computation should be roughly the same as before, but the RAM usage is reduced by around 300ish MB on midsize games with a fair number of factions in a slightly larger than average galaxy. It may also be a fix to yet another memory leak, but I can't be certain. It is a solution to an annoying thread-contention issue that I still don't understand the full nature of, but have decided to work around in this particular case by just making everything so much more efficient in the first place.

This build sees a number of other bugfixes, and more of SirLimbo's AMU settings being implemented into the base game as options.

More to come soon.
Enjoy!

Beta 3.751 Faction Processing Groups

New build! https://wiki.arcengames.com/index.php?title=AI_War_2:The_Great_Refactor#Beta_3.751_Faction_Processing_Groups

Friday I was out because I was just exhausted and needed a day of recovery. Others went gangbusters on that day and over the weekend working on the game, though.

There's lots of bugfixes thanks to Badger, tom.prince, Puffin, and NR SirLimbo; improvements to contextual info provided by the ARS thanks to Badger; and the start of some of the "extended galaxy settings" from AMU being implemented into the base game thanks to NR SirLimbo.

Additionally, there's a number of new features and improvements in the unreleased DLC3 for our testers there, including some xml work by Puffin Emeritus, which certainly deserves special mention.

The big theme of the largest remaining errors I saw after the weekend were in our random number generators and pathfinding. In both cases, neither piece of code was actually the problem at all -- these were pieces of very good code that were simply canaries for "hey, two threads are using me at the same time, that doesn't work!" In all cases, it looks like the faction-specific Long Range Planning (LRP) code was still able to overlap itself sometimes.

I think that for that to happen, you needed to have some factions that shared data. AI border aggression and relentless waves do that in any game, but if you had multiple copies of a faction, then that would also do it in the prior build. Please note, of course, that all of those cases are supposed to work fine, but that seemed to be the conditions for replicating it for now.

Today I introduced a new xml-driven piece of data called a "faction processing group," which is basically a way for factions to say "I don't run while those others are running. Normally the LRP logic for general factions all runs at once, with the exception of factions that are multiples of one another, or which share some other processing logic like border aggression and relentless waves do. I had existing protections in place to already try to handle this exact concept, but they were code-driven, mildly hidden because of that, and also had a few errors relating to them.

At this point, code that was a bit more scattered around is a lot more linear and has been rewritten to hopefully work quite well. In my brief testing today after finishing this, I don't see these errors anymore, but it's impossible to prove a negative. So if you were one of the testers running into this, please do let us know if things are still an issue. Fingers crossed, I do think I got rid of it, and also fingers crossed, this seemed to be the only category of thread left that had this sort of effect.

More to come soon.
Enjoy!

Beta 3.750 Smooth Simulator

Ho. Le. Mo. Le. Wheeew, new build: https://wiki.arcengames.com/index.php?title=AI_War_2:The_Great_Refactor#Beta_3.750_Smooth_Simulator

This one rips up the entire threading model that we've been evolving for the game since 2016, and replaces it with something more modern, as well as fixing a number of threading-related bugs and other issues. The TLDR is that it's faster than ever, especially on older computers, and it works REALLY well and is way easier for myself and others to debug, too.

The game was downright unplayable for the last few weeks in terms of things like stalled threads and a bunch of cross-threading issues. I've been really tearing my hair out, trying to figure out what on earth was going on, and simplifying code, simplifying it further, and lots of experimenting. Daniexpert really gets MVP once again for truly excellent help with bugtesting and reporting in this arena.

Special thanks also to tom.prince, who had lots of great ideas and commentary on the threading model and things that we'd have to consider. There were several cases where I was going to do one thing, and chatting with tom on discord let me skip a few steps of pain and jump to a better solution.

There's also a bunch of other improvements in here, and various features for DLC3. I am extremely weary, though, so I'm not going to enumerate all of them. I thought I'd be done with this threading thing days ago, and then I started wondering when on earth I'd be done with it at all. Very happy to say it seems to work well now, and if there are remaining problems, they will be much easier for me to debug.

Tomorrow, it will be time to move on and work on other bugs and features that have been delayed by this whole mess. I think this was first on my radar on October 27th, maybe a bit before, so this was QUITE a diversion. The release notes have pretty much the whole story, and the chris-talks-code-gameplay discord subchannel has the rest of it, if you're curious.

More to come soon.
Enjoy!

Beta 3.746 Phantom Ship Syndrome

New beta! https://wiki.arcengames.com/index.php?title=AI_War_2:The_Great_Refactor#Beta_3.746_Phantom_Ship_Syndrome

This one has a toooon of bugfixes. Some of these are fixes to regressions in the prior build, of which there were an uncomfortable number. An amusing one was causing lots of phantom icons to spring up all over the place, in this kind of insanity kaleidoscope. Others were just error spam. These were a result of my improvements to the collections to lazy-initialize, and there were some edge cases in a couple of them that I did not properly account for. That's fixed now.

Hey, also there are several features that had been "DLC3 while testing" that are now part of the base game. Roguelike features like Hidden Galaxy, and then the new Border Aggression feature.

There's a large class of exceptions based around "someone changed a thing on the unit and we're looking at it belatedly and now it's null and time to throw an exception." Those are all fixed, because we no longer allow them to be nulled out. That led to some interim internal hilarious bugs with scaling and stats being off, but now it seems to work fine, knock on wood. So this is a pretty large category of stuff that no longer will break anywhere in the codebase.

There were some pathfinder errors that could still pop up, although these were new ones. These are now fixed. They MAY have been related to thread timings, but I'm not sure. Either way, I made some changes to make them more robust in their defenses, and that seemed to work.

Another big group of bugs were some "invisible dead ships" that would hang around on planets, sometimes with a full forcefield showing, and then also appear on the galaxy map. I am not sure why exactly that started happening, but I have it so that it self-repairs properly now. Most ships don't properly explode on death anymore (but their icons still do), so that's something else I need to fix next week.

Last major known issue that really impacts play lately is the stuck threads issue. I've made some progress on that, in large part due to Tom and in particular Daniexpert doing some debugging. I've corrected a few of the most major cases, and then there's a couple of remaining cases that I now have a pattern for reproducing, and will start chasing down on Monday. In the meantime, as long as you don't reload the game too too many times, it seems to work fine. Or if it's messed up and you reload one more time, then it also fixes itself. I don't think pausing and unpausing works anymore. But overall if there are behaviors you see, or other ways to get it to mess up, then I'd love to have that information.

Hopefully after a lot of these things, code will kind of start settling down. I still have one major piece of surgery, which is to take the necromancer away from being its own faction and to instead be a faction type for humans. That will probably be some bugs. And there are still other known issues like the xml reload locking up (though I need to retest that actuallly), and tutorials and beacons not being re-enabled yet. But a lot of the biggest, scariest things seem to be slowly settling down. Or we're just through the first batch and about to discover a giant new cache of new ones, who knows. Hopefully not.

More to come soon.
Enjoy!

Beta 3.745 Deadlock Removal

New beta build! https://wiki.arcengames.com/index.php?title=AI_War_2:The_Great_Refactor#Beta_3.745_Deadlock_Removal

This one has a lot more going on under the hood than might be apparent on the surface. It's more efficient in how it allocates RAM (which you can see in certain logs mainly), and it is also safer in how it allocates that RAM (thus avoiding some deadlock situations that I had introduced in the last few weeks). So that's very pleasing, but not exactly a marquee feature for people playing. Deadlocks are a special sort of bug that I particularly hate, though, so I'm glad to have it gone.

While I was doing that, Tom has added a new cheat (grantalltechs), and a number of ui improvements and bugfixes.

For DLC3, Zeus has been adding yet more orbital stuff, and the DLC3 testers can now properly test that, too. These orbital bits are suuuuper cool. There's also a new general rare "nasty pick" that is an orbital inertial battery. Playing with DLC3 simply enabled is one of those things that won't make the game harder (that's always important), but just like DLC1 makes it so that there are so many more turret types all over the place (thanks to Democracy and Puffin), DLC3 makes things come alive more with various orbitals here and there even amongst non-orbital AIs.

The galaxy-wide caps are now properly shown thanks to Tom, and Zeus made the super fortress a lot more super.

More to come soon.
Enjoy!