Ladies and gentlemen, I am pleased beyond words to announce that, as far as I can tell, all the AI requirements for 0.8 are finished! Now, I must qualify this: there are a number of NPC classes that do not yet exist in the game, but those that do exist perform almost all their actions, although there are a small number of events currently omitted (rare or unique events like religious festivals and the like). What this means is that around 80% of all NPCs now do 98% of their schedules, and I think they work correctly no matter what kind of strange behaviour the player involves themselves in with regardless to moving, saving, loading, spawning/unspawning areas, and so forth. As a result, I am indeed putting out the interim playtesting/bug-finding release in the next few days! If you emailed me asking to be on the list, you should find an email in your inbox with details of how to download the playtesting release, and some things to look for, within the week. For the rest of this blog post, therefore, I’ll go over the final additions and refinements done in the last week, and then from next week onwards, we’ll finally be on to dialect and speech generation! I’m so excited. But, first…
On Tuesday, Wednesday and Thursday I finished off everything that still needed to be done for castles, and so as far as I can now tell, all the possible NPCs that can spawn in a castle all function correctly with their schedules, their placement, their tracking whether the castle map grid is spawned/unspawned and whether the castle itself is spawned/unspawned, and so on and so forth. One major issue was with sleeping and waking NPCs, and in a few particular contexts guards who should be spawned sleeping in beds were spawned sleeping at their posts, whilst those who should have been on guard duty at their posts were on guard duty in their beds! This got fixed by copying a line of code which should have applied to all guards, but was instead applying to around 90% of them thanks to a typo. I then ran into some issues with entering a castle after the 1080 time of the day (which has 1440 “ticks”, each being ten “turns”) which is when all the guard schedules should switch over; for some strange reasons, the knights guarding the throne room were struggling to spawn correctly and causing a crash, which had *something* to do with beds, but I wasn’t quite sure what.
The “filled” doors are doors to the outside whilst the hollow doors are within one building, so here we see various guards and conscripts going outside. It’s slightly jerky due to all the debug processes printing, but I think it still looks rather snazzy, and I love seeing such a large volume of people going about their day without the game crashing! (You’ll also see slaves and knights in these gifs also just going about their daily business in the castle)
And then immediately after, the guards/conscripts who were guarding outside come back inside and head to appropriate beds:
Here’s a cache guard switching with another cache guards whilst various other guards/knights/etc on the same timetable also move to wherever it is they need to go in order to switch over:
Guards on upper floors wouldn’t behave
As a result, here are some guards and a knight in one of the towers finding their way down correctly, rather than misbehaving terribly:
I ran into a bug whereby I sometimes ran out of beds on certain generations, but only for knights and guards. It took quite some time to diagnose what was actually happening here, but it finally became apparent that when the smallest possible number of beds spawned in the corner/side towers (four per tower, so sixteen total) and the game was trying to place guards and knights in those towers, and there was a cache in the castle, there simply weren’t enough beds, so the NPCs were stuck trying to find a bed; this meant I had to specifically enable their ability to climb up towers to find another bed, but only specific staircases (because the main staircases are in the main castle, rather than in the towers)! The disconnected nature of the upper floors of castles is unique, and has basically required adding in quite a few exceptions to a lot of NPC behaviour which ordinarliy wouldn’t have to think about impossible paths on a given floor.
After that, though, things went quite smoothly with servants, slaves, and monks. Here we have a basement in this castle containing the castle’s slaves, who were all going about their day most of the time and then filed into the basement as time went by:
And monks sleeping at night in their quarters:
I then turned my attention to priests, who – in castles – can fall into two categories. In religious nations you’ll find a single large chapel with a priest walking around inside, whilst in nations that have freedom of religion you’ll find a large number of small chapels, each with a priest (and altar, book, etc) of the appropriate religion. Here’s a priest wandering around a full-size chapel for a nation dominated by a particular religion (you’ll note various servants coming and going at the same time), and then various priests in smaller chapels in a castle in a nation with a plurality of religions:
And I must say there were some cool religions in this castle. Jaguars for the jaguar god!
Then, servants. They work the same as slaves (aside from being on the ground floor instead of underground), and these worked pretty much immediately thanks to all the code in place for slaves. I then moved onto torturers and jailers, who should be spawning in a different section of the basement, away from slave quarters (if slave quarters are present) and who keep to a very simple schedule. Sure enough, these folks seem to work perfectly well now too. Here’s one of them wandering around (I also really love how under-castle jails look, don’t you?).
And heading to bed:
And here’s a torturer checking out the cells under their control (where unfortunate people will one day appear), and in a later version there will be various unpleasant things in the centre of this room, which will vary from nation to nation (so different nations have different methods of torture, if torture is their thing).
And slave quarters and a dungeon in the basement of the same castle, with two different staircases. This is a rare-ish scenario, but meant I had to make absolutely sure that slaves returning to their quarters knew which staircase to take (servants, being on the ground floor instead of the basement, don’t have this issue)…
And that’s pretty much all the NPCs for castles! In future versions I may add in a couple of extra NPCs, like book-keepers for archives and the like, and also I need to add in concubines at an appropriate point – and the actual leaders themselves! – but for now, castles still appear very active when the player wanders around them, and that’s what matters for 0.8.
Final Check, Final Bugs
The last thing to do before sending out the playtesting release is to active all possible AI actors and spend a little while wandering around the world and trying to break them myself. I’ve now done so, and to my absolute delight, I have thus far discovered that everything seemed to be working correctly, although I do still harbour a tiny, tiny concern that certain NPCs in certain houses might not always appear in their houses at the correct times, depending on the player’s actions… but I couldn’t produce any bugs here, so that’s down to be super-secret super-elite playtesting team to figure out.
I’m also going to implement a few debug tools for my playtesters, so they can now look at a debug print-out which shows all the important NPCs in that area, where their homes are, what their current tasks and schedules and objectives are, and so forth. This, naturally, will not be in the final release, but I thought it was a pretty essential feature to maximize the potential of the interim playtesting beta.
Although I have ever confidence in my team, the complexity of all this stuff does mean it has to be possible that the final 0.8 release will go out with a few minor issues still in place. This would be disappointing, of course, but so long as there are no AI related crash bugs present when 0.8 hits the shelves, I’ll be content – it would obviously be even better if there were no AI bugs of any sort whatsoever, but I’m being realistic. Pathfinding and scheduling is massively complicated already and made even more complex by the variety of permutations of spawned/unspawned/loaded/saved areas the player can bring into existence or push into the background through their movements in the game world, and despite my best efforts, I’m sure it’s still possible for an NPC to duplicate, or to vanish into nonexistence, or something else of that sort. But we’ll see! Maybe the playtesting release will be remarkably stable and nobody will find any problems whatsoever.
DIALECT GENERATION! For the next week or two I’ll be working on the underlying mechanics for generating different styles of speech for each in-game culture (in the average game we need to produce around 40 very different styles of speech, and ideally many tens of thousands possible across a long enough stretch of time). I’ve started to draft this in various forms over the last month or so, and so next week I’ll give you all a run-down of what I have in mind here. After that we’ll be onto designing the conversation screen! I’ve also been giving this a lot of thought, and I have some idea how this is going to play out, and how it will connect to the dialect/sentence generation stuff I’ve been quietly putting together and experimenting with in the background. See you in a week!