Looking at a game a clueless stranger would see a handful of moving objects. A newcomer sees a GUI and units wandering around. A passionate player will see a whole living world. A modmaker sees a game full of complex mechanics and AI, hidden links and modding perspectives. A programmer sees a lot of code behind the scenes, data structures, the outline of an architecture, and megabytes of a source-code.
Note: Of course there are lots of other things that contribute to a game (art, assets, logic, mechanics, ideas), but for simplicity’s sake let’s focus on programming alone for now.
Taking a step further I would like to add one more piece from a technical point of view – utility tools. They are mostly invisible, but a game without them is impossible. What are they and why they are noteworthy? That’s very simple – without utility tools the game is nothing more than a skeleton, beautiful in its inner workings, but hollow and lifeless.
Tools fill the game with the “game”. One of the most widely known tools in KaM Remake is the Map Editor. Yes, you heard it right – MapEd is an utility tool, it is not part of the game itself. Yet MapEd is one of the most important pieces, for it allows the game to be filled with beautiful landscapes, green hills and fast rivers, mountains full of gold and iron that are so needed for a good fight 🙂 Many mapmakers work hard to make all this beauty and the MapEd is their servant with many brushes and settings and controls.
But wait, there are other tools. One of less known is the Translation Manager. This handy fellow allows the game translators to easily add new translations into 20+ languages. Of course that would not be fully possible without one more tool – Font Editor, the tool that lets you edit the font glyphs for all these languages.
There is also the less used Campaign Builder – tool to make a bundle of several maps into a story, with a tactical map and briefings. The Script Validator follows, with the addition of dynamic scripts this new tool comes in play – it let’s you quickly check your scripts for errors without needing to start the game.
There’s also RXXPacker – the tool needed to bundle sprites into rxx packages. Sprites are packed and archived to take less space on HDD yet be in format suitable for inner rendering routines. Soft shadows are generated on the fly in this tool as well. Alongside comes RXXEditor – a tool to see the RXX pack contents and check the sprites offsets and visuals of the images and masks.
Some one-time jobs are done with TilesetResampler and its elder brother Batcher – a true swiss-army knife that allows to do batch script updates and changes in maps.
We also have some Unit Tests. Those are tools that check certain areas of code for correctness.
PathFinder is another one-timer that we made to compare 3 different pathfinding algorithms to pick the best one in terms of complexity and speed:
Runner is what allows us to test gameplay balance, performance and especially AI. It runs the game without anything but the logic (sound and video are disabled). It can simulate 2 hours game time with 6 AIs on Across the Desert in few minutes, so we see how AIs performs in e.g. weapon production. Simulating 1000 fights between 200 militia armies and graphing the results – easy deal :) On this screenshot you can see times in msec it takes to compute each games step:
BugParser lets us maintain a list of crashreports we receive:
There is a dozen more one-timer tools that are too specific and uninspiring to show here, yet they exist as well (Net tests, algorithm tests, etc).
And there are tools we miss: Unit Editor to easily tweak units properties, House Editor to edit house settings, Tile Editor, and many others. We haven’t written these tools partly because hard-coding values works good enough and partly because they would make a good first task for a new programmer wanting to join our development team.
Behind tens of thousands of lines of code in the actual game, there’s also comparable amount of utility tools. It may never be seen outside, but making a game without any of these tools would be next to impossible.
Very well-written and an interesting read. I just love the image about the path-finding algorithm. You explained that there are different possibilities for path-finding and you select the easiest and fastest. May I ask which algorithms you use and, also, do you take into account the placement of houses or only natural surroundings? (Having a background in Operations Research, I think it will suffice to just mention the name of the algorithms to me)
We now use A* with a binary heap, which is much faster than our old A* system which didn’t use a binary heap. We also experimented with an A* and Jump Point Search (JPS) algorithm, but it wasn’t faster than A* with a binary heap.
Krom can give a more detailed explanation since he wrote almost all of the pathfinding code as well as the experiments with different algorithms 🙂
The path finding takes into account all obstacles, and it also tries to avoid making a path through other units (they are given a higher weighting for that step, so the path will prefer to take a step around the unit).
You can see how it works by starting a singleplayer game, pressing F11 to open debug controls, and then dragging the passability slider to CanWalk. This will show you which tiles can be walked on. You can also select from the menu Debug -> Show Units to see unit routes.
Hi! I have owned this game since 1998 and I’m glad to see how devoted other people are to this fantastic game. I have some suggestions how to make this game better. Would you mind if I share my opinions? Here we go:
* Ability to create virtually unlimited mapsizes. Only computer power will decide if the game would lag or not. Limits is a pain.
* When you build a very large city that covers much of the map, strange things will happens where serfs are walking with wares to the enemy, getting killed, and then the game crashes. Rewamping of the code to prevent this fatal error would be much welcome, since we all dream of building these large cities without limitations. Once again: System requirements and computer power should be the only limitations for this. Ingame-limitations not.
* Wall-Building, with smarter AI (ofc!). Also; The AI will not “give up” or run out of resources after 15h, but keep expanding their town and hostily build up their forces to even greater strength. You want to have this feeling “I’m building this large town here… but what is my enemies doing..?” and the sense of a strong opposite power on the other side of the map.
* Game should not crash when the laborers gets interrupted in their road-building. Also better path-finding to avoid crampedness at the storehouse (especially in larger cities, this is a pain). Also, enemy serfs and walk on your roads and vice verse. The should also be a way to delete or cancel a construction like farmland, roads or wineyards. If done so, the serf carrying the stone or wood, will turn back to the storehouse with the ware.
* Better crossbowman/bowman-handling. Another pain. You task them to attack the enemy and instead of shooting, they goes up just to get slaughtered.
* Ability to select one of your men and press the DEL-key (like in Age of Empires), instantly killing him. This is to save your town in severe situations where you are running out of food.
Thanks for writing Simon! 🙂
We have been working on the Remake for several years and now it is safe to say it is better gameplay than original game. You should try it!
# Mapsize limit is there because when you play multiplayer games you cannot rely on everyone having the same powerful PCs, and if just one lags – whole game will lag. Also, creating a huge map is a huge amount of work. We have already raised the mapsize limit to 256×256. Another issue is that KaM gameplay is not suited for huge maps – e.g. you cant build disconnected towns.
# That should not happen in KaM Remake. If you see such thing please email us a savegame.
# We keep on working on AI, but it is rather hard to make it play well in fact.
# This feature is planned 🙂
# This has been much improved in latest release (KaM Remake Scripting Demo r5503)
# We discussed that and decided against it. No good ruler will kill his own men with such a cowardice.
If you have more questions please feel free to ask them in forum – there are many people discussing the game and offering ideas there 🙂