PROCEDURAL CASTLE GENERATIONAt long last, castles are generating, and you will be able to visit them in this release!So get some food and drink, relax, put your feet up, and sit back for a detailed exploration of how castles are going to generate, what you’re going to find inside them, what the player will be able to do there, how you’ll gain access, who you’ll find living there, and so on.
Firstly – castles are one of the only two districts which are barred to player entry in the current version of the game (the other being dockyard districts). I tried a few early models of castle generation in the present release but just couldn’t find something which worked relatively quickly, generated them in the detail I wanted, and ensured that they were aesthetically consistent with the rest of the nation – not to mention that I was redoing how all the ideologies work and I wasn’t quite sure how these were going to tie in (more on this below). So I decided to leave them until this release, and now that NPCs are almost “done” and the majority of the bugs created over the last few months have dealt with, I realized the time had come to implement castles.
What goes into a castle? Castles are located in cities and take up a full district in that city. As I’ve talked about before, policies/ideologies have been completely reworked to provide physical and structural changes to each nation, rather than more abstract things. Therefore, the “Zealotry” ideology has religious buildings spawn in all city districts; the “Conscription” ideology places a barracks in every town; the “Isolationist” ideology creates city walls; “Theocracy” always ensures a crypt beneath a cathedral; and so on. I’ve now extended this system to castles, meaning that the rooms you find inside each castle (aside from the standard halls, guard quarters, etc) are entirely dependent on the ideologies of that nation, and forms a kind of microcosm which reflects the city around it (and all the people in that nation, and its towns and settlements, and its citizens, and so forth).
So, a Monastic nation will have some monks resident in the castle, a Vassalage nation will have a hallway depicting the banners and armour of all its important houses and families, an Imperialist nation will have a room filled with trophies from past conquests, a nation which cares about Aesthetics will have an art gallery within the castle, one which believes in a Penitentiary justice system will have a dungeon, and so on. This therefore means that each castle can have a range of special rooms, from the smallest possible number of two (I think!) for a nation where almost none of its polices necessitate special rooms, to a grand total of sixteen rooms for a nation which happens to have chosen ideologies which necessitate something special (and everything in-between). As ever I wanted castles to reflect the aesthetic/geometric preferences of each nation (square, octagon, circle, diamond, cross) and also, of course, to actually look like a castle on the outside with walls, moats, and so forth. This leaves us with a “two part” castle system – generating the outside of the castle which is the “district” of the city, so to speak, and then generating the inside of the castle.
Here we have an example of a “castle district”. In the design of this generator I wanted to accomplish several things. Firstly it should look defended, aside from the city walls which interpenetrate each city and delimit one district from another. This means walls and/or moats depending on the particular policies of that nation. Secondly, it should fit with the rest of the nation: this obviously means the usual consistency in brick colour, but also in shape, so we see here the castle for a octagon nation (and there will be others shown elsewhere in this entry), and the moat and the walls both clearly reflect this aesthetic preference. Thirdly, of course, it needs to fill up the district – splitting cities into square districts is an acquiescence to various gameplay and technical requirements or decisions, and trying to get a singe building to fill up an entire district just wouldn’t work (cathedrals in city centres, for example, are massive, but only take up around 1/4 of the district at most). Therefore, what else do castles often have? Well, castles (and stately homes/mansions/manors more generally) often have expansive gardens, so I decided to take a leaf from the mansion generation system and add some rather snazzy gardens into the mix as well, behind the walls (these will have more detail once I redo plants in some later release). Some more of the district is then “taken up” by adding small shape-appropriate towers into the external wall of the district as well as the internal; I think this makes quite a nice visual effect, and helps the districts with smaller castles (as castles can vary in size depending on how many ideology-dependent rooms spawn within them) feel a little less empty and devoid. Ultimately it is tricky making the entire district full via a single building, and there is more variation I want to add in the future, but I think it’s working well enough for the time being (as there will also have guards on patrol and so forth to add more detail). Here’s another example for a cross nation:
We then come to handling the inside of a castle. As above, there is a significant range of possible rooms, *and* each possible room has its own layout, and these need to somehow be shoved correctly into a castle of a particular shape and size. Suffice to say, this is no easy programming task, but the game can now select from a range of preset “starting points” for castles, and then split and subdivide rooms in a number of ways, and then add in the special rooms (and the ordinarily rooms) in sensible locations, and do this for any number of shapes, sizes and permutations of important rooms. Like most of the most complex generators in the game this is a mix of PCG, handmade regions, and large databases of areas that are somewhere between the handmade and the procedural. This system took the best part of a week’s coding to complete, but now it works (I think!) for any value (within the scope of possible values). Castles always contain a great hall and guard quarters (and/or soldier quarters depending on ideologies) which are positioned in the parapets/towers surrounding the castle. All castles then contain a range of studies, dining rooms, bedrooms on their upper floors, and so forth, and then a throne room situated somewhere on the ground floor, although the precise nature and position of this throne room varies for democratic/ theocratic/ stratocratic/ monarchic nations. Alongside these are all the ideology-determined rooms, of which there are dozens. Rooms that might otherwise be similar – like quarters for monks, servants, soldiers, etc (how many ways can you make a room with a bunch of bed distinct??) – always have some variations, so they might have different floors, or different extra furniture, and so forth, so every kind of room will be distinctive. Also – you see those rooms below with just tables in? Those will soon contain books, maps, trophies of battle, tributes from weaker nations, etc, but for now,they’re just tables! So, here are two examples of what the bottom-floor interior of a castle might look like, taken from an octagonal castle and a cross castle:
Naturally, not all castles have an “open” interior section that leads back outside, it just so happened that the two I generated for this entry did! More important rooms means a larger castle and a lower chance of an open inside. Similarly, there are various things that can appear in corridors – banners showing the coats of arms of vassal houses, holy books on pedastals, placards noting arena champions, and various other things – but I haven’t quite got around to adding those in yet at time of writing (but they won’t take more than a few hours at most). Similarly, see the odd empty room? Those will be money caches soon. Also, if you see some unknown symbols… well, you’ll have to explore some castles to find out what those are! Next we also have some top floors, containing the master bedroom for the ruler (and potential space for a harem, or consorts, or multiple partners, if the civilization in question goes in for that), then various bedrooms for the various offspring of the ruler, guests, and so forth, again with a nice lot of variation for different shapes and sizes of castle – these are of course rather similar to the ornate quarters in mansions in officer quarters in military districts, but there is only so much variation one can give to a bedroom. There are also the upper floors of each tower on each side, which lead out onto the roof! I’ll get pictures of these up at a later date as I’m still finishing them off, but you’ve no doubt seen the bedrooms in URR’s mansions, for instance, so you get the basic idea. There are also various rooms that spawn underground too, and various secret rooms as well…
What about the castle’s inhabitants? Well, naturally we’ll have the ruler; we’ll have any assistants, clerks, eunuchs, partners/consorts, and so forth; potentially priests and monks if the ideologies suit it; lots of guards and soldiers, though again their number and placement vary for various reasons; servants and/or slaves; and any guests, though I’m not quite sure what guests we’ll have visiting rulers. The rulers will of course sometimes leave the castle to preside over parliament, meet foreign dignitaries, and that kind of thing, but that’s in the future. What about access? I’m not going to implement the key/permission system in this release, since most of the things that will be later required to gain access to areas aren’t implemented yet anyway! You’ll remain free to wander around the world for the time being and meet the people there and talk to them, but it won’t be too long until you’ll need the appropriate keys and permissions to gain access to the most important areas; for now, therefore, guards will let you wander.
So there we have it. Castles are now, I would say, as detailed and interesting as cathedrals, which certainly makes a lot of sense – these should be the two most impressive structures in the world (although I have an idea for some special massive buildings in the future, like rare one-off huge prisons, or asylums, or arenas, and so forth). Here’s a comparison pic of a generated castle and a generated cathedral (the two largest structures you can find) to give you a good idea of the similarities and differences. I’m immensely pleased with how these now look and I hope you like them too!
Next week I’ll probably post about the final removal of (hopefully) all remaining bugs, at which point I would hope that the game will be stable, or at least as stable as a massive release of this sort can possibly be because major wide-ranging playtesting by a community rather than an individual. Then, hopefully, I can finish off AI/pathfinding and clothing stuff before the end of the year. It remains a hugely audacious goal – I need to get all nomadic clothing and tribal clothing generated, and get every single NPC scheduling and pathfinding correctly on the “human” rather than abstract scale – but I… think it can be done before the end of December. See you all in seven days!