One weird trick makes civilization v much faster

civilization IV players hate this!

the thing you came for

you like civilization 5, huh?

well, now you can enjoy it even more. this one weird trick makes civilization's processing go brrrrr. faster as light. lickety split. instructions in the linked webpage.

wait, what the heck?

Civilization V, like Civilization IV before it, uses a Lua interpreter to load information into the game, to build, and execute AI decision trees, and to execute routines. the diplomacy system? controlled by a .Lua file. the menu system? controlled by Lua. this allowed development of the game to occur very quickly in a collaborative setting without having to constantly build and deploy new versions of the game -- a Lua file is a plain-text file, easily shared.

Lua interfaces are not exactly uncommon. It's a very powerful scripting language, one that open source projects like Minetest use to enable users to create and distribute modifications. An entire game-making engine, LOVE2D, is built on it.

Lua is somewhere between Javascript and Python in terms of ubiquity, ease of development, and features. Created and maintained by a team at the catholic university PUC-Rio, Lua has been around for as long as the World Wide Web. It’s probably older than your children, and definitely older than your car. Like other programming languages, it routinely gets extended with newer updates and new features. Not all Lua functions are always integrated into games; some games only expose a narrow set of commands and data structures to a Lua API - reserving the real calculations for the meatier and faster native program binary.

Interpreted languages like Lua can be performant, but not nearly as fast in executing instructions as native programs. Enter the JIT. Just-in-Time compilers/interpreters convert script into machine language, making the exact same script execute dozens if not hundreds of times more quickly. JITs sometimes omit or rewrite how functions work; some JITs keep variables in memory after a function is completed, for example.

LuaJIT, the gold standard, is built to Lua 5.1 specifications. However, LuaJIT has not received a complete stable release in years. So, as open source projects are wont to do, someone forked it. MoonJIT received one stable release before the maintainer quit – but the stable release did include some significant performance upgrades over LuaJIT.

Civilization V players have been using JITs for a while. Well, some of them. The version used by those who do is LuaJIT 2.0.5, which is positively ancient now.

So. Needing a new, faster performing Lua interpreter, what’s a person to do but compile moonJIT from source code?

And that’s what I did.

It works beautifully.

5 Likes

Ima gonna try this on Civ 6 on the iPood!