Saturday, June 1, 2013

Introduction

I've been meaning to start an ongoing blog about interesting modifications to the C2C codebase (and/or interesting experiences in making those changes) for some time, but never really got round to it, so now seems as good a time as any to finally commit some thoughts to 'paper' (unlike Mr. Ives, I like skeuomorphism, even if it's only the metaphorical kind).

First of all, a few words of introduction to C2C for those who somehow got here without being familiar with it!

C2C (aka 'Caveman 2 Cosmos') is a mod for the game 'Civilization IV', a turn-based strategy game in which you build an empire, expanding and learning new technologies as you go.  See http://forums.civfanatics.com/showthread.php?t=444594 for specifics on the C2C mod.

Firaxis (the authors of the 'Civilization' series games), chose to open the game to modding in fairly extreme ways by exposing both an XML-based entity definition system (by which new unit types, buildings, technologies, etc. can be defined), a scripting interface (which allows functionality to be scripted in Python), and also by open-sourcing a DLL which implements the game world and the AI for computer-controlled players.  Just the graphical front-end is closed, but since pretty much the entire ruleset of the game, and all the AI is in the open-sourced DLL part, the changes that can be made are almost limitless.

C2C takes this to something of an extreme, by making very extensive changes to the DLL (significantly modifying, and adding to the ruleset, which in turn is exposed to the XML and scripting layers via an enhanced API and XML schema).

My involvement is primarily with modifications to the DLL code (which is C++), principally in the following areas:
  • Performance optimization - many areas of the original Firaxis code have been reworked to improve their performance, and especially their scalability (C2C defines an order of magnitude more entities than the original game, and also tends to be run on far larger maps, both of which stress aspects of scalability in the original code).  Areas that have been significantly reworked include:
    • New path calculation engine (to determine best legal routing for units across the map)
    • New trade network calculation code
    • Introduction of multi-core processing (the original was entirely single-threaded)
    • Greatly optimized AI evaluation calculations (what to build, what to research, etc.)
  • AI improvements - as new capabilities are added, the AI has to be taught how and when to make use of them.  Also there is an ongoing effort to increase the effectiveness of AI players, and to improve the scalability of the more time-consuming AI algorithms (which is really performance again)
My intention, with this blog, is to make postings about particular changes that are either interesting in their own right, illustrate some unexpected discoveries (either about C2C, Civilization, or programming generally), or which need to be explained in some defined place for the benefit of other modders.

I may well write posts on some things that have already been done, because they meet one or more of the above criteria (e.g. - the new pathing engine, viewports, and so on), but the thing that triggered me to start this now was the need to write up changes I'm making for multi-threading of the turn-processing.  Consequently the next couple of posts will be about that in on way or another...

No comments:

Post a Comment