• 📚 Admin Project Update: I've added a major feature to PictureBooks.io called Avatar Studio! You can now upload photos to instantly turn your kids (and pets! 🐶) into illustrated characters that star in their own stories. Give it a try and let me know what you think!

Mini-engine progress

Hello, since you are at the UI layer, coincidentally i did plenty UI beautification and enhancements in AdvCiv-SAS, my mod based on AdvCiv 1.12 (that also enhances the AI so it is much smarter/stronger / more efficient although not the topic here i guess but anyways etc.)

to see how it looks, i'd suggest looking:
- at the github's main readme where i have screenshot examples: https://github.com/wonderingabout/AdvCiv-SAS/tree/tech-rework
- alternatively the cfc mod's download page where i have screenshots (edit: but they are from latest stable of last week, which doesn't include any of the advisors rework, so prefer the above ideally i'd say, or the cfc discussion thread for updates anyways etc.), link to the main changes guide there, cfc dicussion page link if adventurous or such, etc.: https://forums.civfanatics.com/resources/advciv-sas-simple-advanced-strategy.32513/

i believe the UI reworks i did are worth the look, not sure how well they fit in this project's goal though, and admittedly i am not a pro coder super champion xd but with the help of AI and some intuition or whatever you call it i like very much the beautification and enhancements (more UI info in sevopedia, and recently i am redoing the advisors as well (see github for screenshots or wherever you can find them) i added.

i tried to make display more dynamically adjust to game screen's resolution rather than some hardcoded values (and more generally trying to use more of the screen's available space while keeping key display available, making display mroe symetric or pretty, etc.).

If further curious about the mod feel free to browse through the main changes guide as well (https://github.com/wonderingabout/A..._AdvCiv-SAS/Docs/README_Main_Changes_Guide.md).

Hopefully helps (and does me some advertising while doing so xd) but maybe helps :)


edit: since there's no harm (i guess), i guess i can show some screenshots here (see github for details or updated ones):
 

Attachments

  • 0.620_sevopedia_leaders_sample (1).JPG
    0.620_sevopedia_leaders_sample (1).JPG
    1 MB · Views: 46
  • 0.680_sevopedia_units_sample (1).JPG
    0.680_sevopedia_units_sample (1).JPG
    806.8 KB · Views: 42
  • 0.510_foreign_advisor_bonuses.JPG
    0.510_foreign_advisor_bonuses.JPG
    233.6 KB · Views: 40
  • 0.511_foreign_advisor_info.JPG
    0.511_foreign_advisor_info.JPG
    331.5 KB · Views: 44
  • Civ4ScreenShot0980.JPG
    Civ4ScreenShot0980.JPG
    331.6 KB · Views: 21
  • 0.610_sevopedia_searchbar_example (2).JPG
    0.610_sevopedia_searchbar_example (2).JPG
    218.1 KB · Views: 17
  • 0.34_Techtree_ingame (2).JPG
    0.34_Techtree_ingame (2).JPG
    296.2 KB · Views: 11
  • 0.516_info_screen (1).JPG
    0.516_info_screen (1).JPG
    297.1 KB · Views: 9
  • 0.516_info_screen (2).JPG
    0.516_info_screen (2).JPG
    301.3 KB · Views: 8
  • 0.516_info_screen (4).JPG
    0.516_info_screen (4).JPG
    363.6 KB · Views: 7
  • 0.516_info_screen (3).JPG
    0.516_info_screen (3).JPG
    396.2 KB · Views: 7
  • 0.517_victory_screen (1).JPG
    0.517_victory_screen (1).JPG
    409.4 KB · Views: 5
  • 0.625_sevopedia_handicap_chart (1).JPG
    0.625_sevopedia_handicap_chart (1).JPG
    248.2 KB · Views: 4
  • 0.611_sevopedia_index_as_category (1).JPG
    0.611_sevopedia_index_as_category (1).JPG
    231.3 KB · Views: 2
  • 0.611_sevopedia_index_as_category (2).JPG
    0.611_sevopedia_index_as_category (2).JPG
    184.2 KB · Views: 3
  • 0.400_city_screen (1).JPG
    0.400_city_screen (1).JPG
    363.4 KB · Views: 3
  • 0.626_sevopedia_game_speed_chart (1).JPG
    0.626_sevopedia_game_speed_chart (1).JPG
    211 KB · Views: 4
  • 0.626_sevopedia_game_speed_chart (2).JPG
    0.626_sevopedia_game_speed_chart (2).JPG
    433.1 KB · Views: 4
Last edited:
Hello, since you are at the UI layer, coincidentally i did plenty UI beautification and enhancements in AdvCiv-SAS, my mod based on AdvCiv 1.12 (that also enhances the AI so it is much smarter/stronger / more efficient although not the topic here i guess but anyways etc.)
And that's another thing, if an engine is compatible with original UI scripts, then it should be compatible with UI mods.

But on the other hand, a redesigned UI system would have proper layout logic and scripts wouldn't need to do layout. Resizeable screens.
 
Thanks, well if it is any helpful feel free to use it i mean.

And if there are better ways that no longer require old scripts, hopefully or maybe the beautification i did can serve as inspiration (or feel free to copy paste steal from xd (credit or not as you prefer although i like it's not required strictly anyways etc.)

The things like the specialist breakdown i added in city screen for example i believe can be handy to avoid tedious hover. Other than that more generally i am not too knowledgeable to go deep into technicalities but i hope this helped :) (Although i'm curious to know how compatible this project is to existing mods and DLL (i saw things like pathfinding logic and all rewritten, but i don't know enough in programming or the project itself to know how grossly easily portable mods like AdvCiv would be to integrate it with (the AI logic, etc.), if it would be minor or like rewrite most) (i saw this uses python 2.4 somewhere when i glanced too which may explain why this is comaptible with Ui mods right (if i understood it correctly and am not mistaken in some way))
 
(Although i'm curious to know how compatible this project is to existing mods and DLL (i saw things like pathfinding logic and all rewritten
The changes would nevertheless need merging if you want to use mini-engine DLL improvements.

Plenty of AI procedures have parallel versions, and the pathfinder can take a turn limit.
i saw this uses python 2.4 somewhere when i glanced too which may explain why this is comaptible with Ui mods right
Python 3 might work too, depending on if the scripts do anything that depends on python version, like the division operator. But really, the decider of compatibility is the engine, as that's what provides the UI python API. The DLL doesn't really do much with UI, it's more concerned with what the UI does, which is what BUG BULL extends.
 
I see, this is outside the scope of my knowledge xd if i may say (i.e. i don't understand too much of these), but from i understand it looks like this is fairly similar to base civ4 code, but with significant differences, meaning i'd have to manually insert whatever C++ or such changes i made into the DLL one (which i assume uses BTS "raw" AI and logic right?) (if i'd ever do i mean) (by parallel is this what you mena, fairly similar yet different ones?)

I don't mind using python 3, but since the current work and i'm not too knowlegeable about these, i don't have a preference and am fine with whatever works xd. Since 2.4 since to run fine, i have no issue keeping it, but if and that's a big if i'd extensively implement my changes in this project (unlikely although would be nice, but maybe takes too much time, however who knows (and some technical knowledge gap in skill i need to overocme xd too hopefully :)) (if i do)).

On that note, i applied ruff (https://github.com/astral-sh/ruff) optimizations to most of the python code (including BUG and such) , hopefully not breaking anything, as some undeclared variables serve purposes as i foudn later in sevopedia promotions (then i just kept the instruction whatever it is named but without a variable else the remainig promotions were missing in the list)

Like the DLL i'm not too specific, the current works fine and is simple and i like it, open to whatever else as long as it works especially if it's simple :) (else wil adjsut (if and again a big if i ever ideally implement my changes in such a project (not sure as tedious in time, although interesting)) (and things about pathfinder i honestly have no clue about and only do surface and AI logic enhancing for the most part, not deeper mechanics rewrite :)) (but i hope my mod makes AI and UI and QoL much mroe enjoyable as such (each their strengths xd i guess but anwyays etc.)) so thanks for all feedback and open to further info on this or details/explanation if you'd want to clarify them thanks.
 
by parallel is this what you mena, fairly similar yet different ones?
Multi-threaded versions of AI procedures written along-side vanilla AI code. So if you change vanilla AI code, you'll need to update the parallel version.
Since 2.4 since to run fine
As said, changing python version is a big deal. All scripts would need to be checked for incompatibilities and updated. Especially map gen scripts. There are a few reasons to upgrade python: can just use the latest python packages, can use the latest pybind, may have more performance and multi-threaded capability, and you can actually use python 3 stuff in scripts.

For me, it would not be worth upgrading python unless it's the last thing needed to get good performance on gigantic maps. Before you upgrade python, you'd try extracting more parallelism from DLL code. Because even if python was infinitely fast, it still wouldn't be good enough right now.

And that's the other possibility, "just" rewrite the DLL with parallelism in mind. This is likely needed for the performance I wish for, if you don't change AI behaviour. Although, you may end up needing python 3 multi-threading in the end.
and things about pathfinder i honestly have no clue about and only do surface and AI logic enhancing for the most part, not deeper mechanics rewrite
The complicated thing is the CvUnit::canMoveInto family of functions. That thing is cached into pathfinder bitmaps. Any changes to that function will require meticulously updating caching code.
 
Ok thanks i think i got most info, if not i'd get the rest as i dive into this as i do.

For now, it looks simpler to stay on current base advciv based code and add whatever features i want (ai, ui, etc.), an dmay always be so due to simplicity or perhaps even just availability depending on when/if this project ideally goes further i mean but anyways etc.

About these complicated things:
Spoiler a current fairly rare but reproducible crash i have in my mod if i may ask about it i mean: :

i have a recurrent issue in my mod (reproducible crash) related to CvSelectionGroup::plot (git branch), which i have documented in this google drive folder link

Ideally i should definitely not ask here, but as this is a reccurent issue i'd be very thankful to any tips (or you could tell me where i could continue or post such a discussion and i'll delete this info from here as it is unrelated). So so far i have this windbg sceen (and the .dmp in drive, save file in corresponding git branch), but i don't know what to do of it xd as i don't know too much about these (but open to learn a bit or apply a fix or try to if any!) thanks :)

analyze -v windbg cvselection plot.PNG

 
Last edited:
Thanks, i'll (try to xd but anyways etc.) look into it more and add more data and all or/and maybe try claude code or whatever if it helps and post it in the relevant thread then :)

Thanks for your feedback as well, although i didn't take the time to reply fast enough, your info is helpful.

I'm doing other things and as the issue is not too urgent (although annoying when it happens, but it can be avoided by just doing a different number of turns of autoplay (e.g. if it crashes 34 turns from a save file or a specificed turn, instead of autoplaying 100 turns autoplay say 25, save, then autoplay any amount like 75 or 50, generally works around these, plus reloading helps too)), i would do so at a later date if i ideally ever do xd (not sure though).
As this is not relevant, not spamming here, will try to add the data in the relevant thread if i ever do, thanks for help in all cases :)
 
Last edited:
And that's the other possibility, "just" rewrite the DLL with parallelism in mind. This is likely needed for the performance I wish for, if you don't change AI behaviour.

Civilization IV was released 20 years ago and people where able to play it back than. Now 20 years of CPU and Compiler development later we a need multi threaded approach to be able to achieve the same???

I'am no game developer but if the eco system for game development is that bad it's probably because otherwise people wouldn't buy new hardware each year.
Sad times really just like Visual Studio has gotten slower and slower despite running on much faster CPUs these days.
 
The single-threaded design is difficult to parallelise and did not use algorithms that are efficient for giant maps, so hardware improvements won't be enough. Things still aren't efficient enough. AI would need reengineering. Like, perform AI for multiple privateers and barbarians in one go, use hierarchical pathfinding, have a thread-safe unit move routine.

But for Huge maps, it's fast enough now for testing.

Visual Studio
Nevermind the performance, I wish they'd fix my modules Intellisense bugs!
 
giant maps
1+ Million plots sized maps are a challenge for sure because the original code wasn't written with that in mind. But that's a edge case and if something like 128k plots would be playable most people would be happy as long as they get a enjoyable game to play.

Nevermind the performance, I wish they'd fix my modules Intellisense bugs!
During the last C++ Committee meeting EDG announced that they are winding down development and plan to make their Compiler Open Source. Time will tell what that means for intellisense, either Microsoft switches to another frontend or they have to develop EDG on their own.

But clangd has it's modules issues as well and the clang developers are looking for people to work on modules because they don't have enough people willing to work on finishing the implementation and fixing outstanding bugs.

Your best bet is probably Clion if you really want to go down to modules route. But you could instead avoid the snake oil and focus on programming instead of working around build systems etc.
 
Your best bet is probably Clion if you really want to go down to modules route. But you could instead avoid the snake oil and focus on programming instead of working around build systems etc.
I so want to use modules. In my next engine, I still use modules for std, common code, and ext libs. But for everything else, Intellisense and the build system just couldn't handle it. I now have this laundry list of bug fixes that I'm waiting on. Well, Intellisense regressed in VS2026 and now has a new bug with import std: The completion list doesn't list things you haven't used. These bugs would be easy to fix if only Microsoft were to give devs time to fix them.

I have thought about CLion now it's free for non-commercial. I should probably try it one of these days.
 
Hello everyone, so glad to see people are still into Civ4.

A couple of questions, please point me to other threads and forums if this is not the appropriate place to ask:

1. How do I optimize Civ4 for use on a 9950X3D with RTX 5090 with 96Gb of RAM?
2. Is it possible to re-scale the UI? I am playing on 7680x2160 ultra-wide.

Thank you!
 
Last edited:
Yes, this is either the wrong thread or you're writing a new engine and DLL yourself.

But Cv4MiniEngine can utilise multiple cores more than base Civ4 ever would. The only thing base Civ4 can use is a single-thread (for the DLL), 3/4GBs of RAM, and a fraction of a modern GPU.
 
Thanks for the response.

I was under the impression that the current Steam version was patched to allow up to 4Gb of memory to be used?

(BTW: I am playing Beyond the Sword if that matters!)
 
Last edited:
Wow! I've discovered an interesting project:
Any chance to port it to Civ4? What do you think?
 
That's the goal. That said, I don't think LLMs can outsmart humans on tactical moves; RL models may (and this modmod opens a way to do that).
Yes, that's how I would feel after seeing https://nethackchallenge.com/report.html#best-overall-agent. Symbolic may be better than neural. My measuring stick is what difficulty can it play at. And can an AI play against Deity.

But you can combine, like wikipedia says. Hybrid AI may be the best possible, which is unsurprising.

With Reinforcement Learning, you can use neural networks. That gets you "Deep Reinforcement Learning".

Or, take a rule-based AI and use machine learning to make decisions: https://pythonprogramming.net/starcraft-ii-ai-python-sc2-tutorial/

With Cv4MiniEngine, there is a way to create a "learning environment" to create these sorts of AIs. Or rather, it shows you how to use the DLL (except that annoying end-turn problem...) and the DLL has performance enhancements. One would basically create a headless engine, or, a server, that a modern Python 3 AI with all your OpenCV/neural network magic could connect to.

Or, go the extra mile and just reimplement whole DLL for maximum performance (with no python calls at all). After all, you'd probably want lots and lots of training data.

Another kind of AI that I keep thinking about is solving for a near-optimal isolated empire. In theory, you could use an MILP or constraint solver (with a python interface), but even optimising for a single city may take forever. Another way is "Monte Carlo tree search", which Total War used, but I would want near-optimality, which would still take forever. The big problem with this kind of thing is huge amounts of symmetry (near-equivalent search-trees for each choice of tiles to work) and poor objective bounds (can't tell which sub-tree is better). If you use an off-the-self solver, the thing to try out may be HiGHS or MiniZinc.

*Another idea is that a sufficiently good AI could be used as hints for the player, like you would have in chess games.
 
Wow! I've discovered an interesting project:
Any chance to port it to Civ4? What do you think?
It is entirely possible. The project is designed with abstraction layers, and only the first two layers depend on Civ V.
 
Back
Top Bottom