Hello friends! Welcome back. I really do hope you have all been enjoying the more regular fortnightly updates recently. I’m pleased to say that – as of yet(!) – they are not stressing me out in the least, and are only helping to focus and drive 0.11 development. It’s good to have this fortnightly check in where something concrete and material has to actually have been achieved, while a full fortnight is also plenty of time to actually sit down and do some substantial feature, or make major changes, or whatever it might be. In recent entries we’ve of course been talking about the generation of poetry based riddles, the implementation of the game’s first ever – and I think quite snazzy – tutorial, as well as major work I’ve done on books. This week’s entry continues several of those themes, and will be taking a close look at an essential new game feature – the journal – as well as huge leaps forward in the underlying code for book generation more generally.

Journal Generation

As mentioned in the last entry, I’ve been doing a lot of work on books. One really important aspect of this, as I said last time, is that the books will all be completely generated at world generation rather than created on-the-fly as the player plays the game. What this means is that we’ll be able to know exactly what page of a book anything appears on, and then integrate those page numbers, or the pictures and text, into further clues which reference or talk about specific pages, rather than just having clues solved via the informational content of those pages. This means I’ve developed a system for the game fitting text and pictures onto pages even when that book hasn’t yet been spawned – it keeps track of how wide and how tall that book is, and then figures out what should go where and what can go on each page. This was a very complex process, although it was made a little simpler by knowing that I needed to implement a system whereby pictures in general would appear on the first page of a chapter or section or heading or something of that sort, and would only be able to appear on the second page of a chapter or heading or section if that particular chapter or heading section was long enough to ensure that no matter how the book generated, and at how it looked, that section would still have at least two page pages in total, rather having fewer pages and thus causing a crash or two images to hideously overlap. What this means is that although book generation is not going to be completely done for the 0.11 release – aside from the journal – all the foundational code for taking any kind of text, and any set of images must be combined with that text, and placing them into a book of any potential within any potential height, and doing so in such a way that the page numbering is always consistent… all this has now been done! I can now input any book text, and any book pictures, and the game can correctly order them and present them for the rest of the game, or the player, to interact with. This is a major technical leap and will be a really vital foundation for starting to develop books in 0.12.

For now, though: what about the journal? Well, firstly, here’s the introduction tutorial entry for the journal:

Let’s talk about what the four tabs mean. I anticipate the first tab finding its way into 0.11, while the other three will be waiting just a little bit longer (the second might appear in 0.11 – we’ll see). The first tab is going to be a narrative, as if written from the point of view of the player character, about everything that they’ve done or seen so far since engaging on the quest. Later on I’ll have a search function added to this, so if you want to look back over all the times that you were in a certain city and see what your character spotted or did whilst in that city, you can do that rather than flicking back through the pages. This will be a really fun and really novel thing to develop in terms of code, but also on the creative level, since I want to make sure that the step-by-step accounting of the player’s journey gives a suitable volume of detail, but also feels human and real, and can create sensible sentences out of any actions the player winds up taking. The second tab will connect to the new ability to “code” and categorise items according to a certain colour and a certain letter, and there you’ll be able to look at all of those which you so far used, and cycle through the items which you’ve given that code to without having to go into the inventory. The third tab, as the above diagram shows, will list things which you done or things which have happened that will have affected how certain people or factions view you. In the future – though not the too-distant future now! – the outcomes of duels will be a very important part of this, but for now it would also be things like behaviours in very important buildings, things which offended important people, how one behaved towards particular religion or nation, and things of this sort. The final tab will then be the place you go to look over what words in each ancient language you have so far had translated, and to adjust how confident you are in those translations.

Now, let’s open the journal! Here’s the front page:

I really love this front page – I think it gives an instant sense of purpose and direction (book generation is currently happening in another file, hence why it’s not a full screenshot, but I’m sure you can imagine it in-game!). As mentioned a few times in various entries in the last year, generating front pages for books is going to be something really fun and interesting – since there’s so much artistic variety I can work in there – but your journal front page is relatively pedestrian, because a) you’ll rarely see it since you’ll be spending most of your time in the four tabs, and b) it’s not a snazzily-published work, but just an ordinarily (albeit… unfathomably large…) journal you’re keeping of your own discoveries. Nevertheless, I wanted to give a few things to further ground the new player – repeat your character’s name, the year, some initial sense of the quest, the purpose of the journal, these sorts of things. I increasingly think that while there is presumably some hypothetical limit of “how many times can we reinforce to the new player what they’re meant to be doing?”… I think we’re still a long way off that, especially for a game with such an unusual core mechanic and core quest system. So for now, here’s the front page, but the important thing is that I’ve started to develop the way that you browse through a book. I debated not having left / right / “>” / “<” work, since ordinarily when you’re looking at items those would take you out of the inventory and have the player move, but since reading a book is going to be a substantial thing, and those are by such a margin the most obvious keys, I’ve decided to go with them – and you’ll see above that a little prompt appears to let the player know that unlike looking at most items, once you’re reading a book (rather than looking at a book) you will need to press Escape to return to the rest of the game. Some playtesting on my own suggests this is fine, but we’ll see how it goes.

Anyway – you can use the left and right arrow keys, as well as “<” (or “,”) and “>” (or “.”) to advance and rewind the pages. The journal is unique because it has tabs, and so as you go through it’ll remove the upper-most tab each time as you get to a new section, as if the tabbed page has been passed over onto the left. For now, if you go too far – i.e. beyond the first tab, the first-person recounting of your adventure – you’ll get a message about the pages being stuck together, but you sense you’ll be able to unstick them soon. (Or I might just remove the tabs for 0.11 to ensure maximum clarity – we’ll see how I feel).

Player’s Activity Log

But now let’s talk about that first tab! This has been a really novel and exciting thing to work on in the last few weeks, and I’m pleased to now be able to show it off. The idea of this first tab is for the game to be able to recount everything substantial the player does, and to do so in an organic and human way of writing, and to categorise this data according to month and year. This was immediately an interesting programming task since I would have to find ways to connect sentences together, to ensure the sentences flow logically on from the previous one or start afresh if they aren’t logically connected, and to ensure a sensible progression between one sentence part and another if they’re both talking about the same kind of topic, but different specifics. To do this I wound up creating what is, essentially, a very minor programming language within URR itself! What I mean by this is that the journal writing code has a number of different sorts of logic triggered by different keywords, and then the actual written content of the journal is constructed through the interaction of those keywords, the sentences attached to each keywords in a list, and what comes before (and after) each sentence. I also, however, wanted each sentence to end with a “…” until it’s finished, and then the “…” is replaced by the end of that sentence, in order to convey that new actions are always filling out the journal. This is all a bit complicated, so I’ll break it down with this example of what I was looking for which I sketched a placeholder. Each line would be one piece of information, and the “…”s show where those lines would then be connected once the later line exists:

So in this placeholder, each line becomes a chunk that should be connected, but only once the later chunk is present. So if we look at the final three lines, this meant that if you descend that staircase, the final line to date in your journal would read “I descended it…”. Then, however, once you opened the chest below, it would change “I descended it…” to “I descended it and opened a treasure chest…”, by combining “I descended it…” and “I opened a treasure chest” by removing the “…” from the end of the first (because sometimes else comes later), and by removing the “I ” at the start of the second (because it follows a “…”), and by adding an “and” to connect the two together. The third line would then get stitched onto both those lines, giving more information, and again removing the previous “…” but only once it has actually been done, thus finishing with “I descended it and opened a treasure chest containing three new clues, some money and a shield”. Then, since that line doesn’t end with a “…”, the next message in your journal, which could be anything – “I departed Raven’s Peak…” or “I talked to a soldier about their weapons…” or whatever – would then start a new sentence on a new line, but would print in the journal with a “…” until something else important enough to get registered in the journal has actually happened to / been done by the player, at which point they get stitched together, the line gets updated, and so on and so forth. This means you only ever have a “…” on the most recent thing in your journal, while everything else would consist of complete sentence. Or, at least, that was the idea in the mockup.

But how to code this?

Well, to make this happen, there are several things going on. The first thing is that the game keeps track of the last three sentence pieces – by this I don’t mean the last three sentences in the journal, because those might consist of several pieces, but the last three sentence pieces. Each sentence piece is then tagged with one of three pieces of logic which I’ve called “GO”, “MID”, and “END” (here think of things like AND, OR, XOR, etc). If the previous was an END, then the next must be a GO. If the previous was a GO, then the next can be a MID if it’s on the same topic as the GO, or if it’s on a very related thing and follows on specifically from that GO, but if not, then it will be an END – meaning the most sentences in the journal consist of two pieces, where the player did one thing, and then did another thing which doesn’t have to be related (e.g. “I bought a katana, and then I departed Blackhill City.”). If it is a MID, then it must resolve in an END next time, unless the topic is specifically continuing from the thing that sentence is a MID about (so that is stored and tracked as well). Then we add a bunch of code to add and remove things like the three dots, “I”, “I also”, and to add commas and “and”s as well, but only when these sentence pieces are being stitched together in the journal – not when the three most recent sentence pieces are being secretly stored by the game behind the scenes. So, at a given moment, the three most recent pieces being stored might look something like this:

The first part of each tuple is the text, the second part is the logic for that sentence piece, and the third part is what nature of sentence piece it is, i.e. what topic it is taking about, and hence whether further sentences can be attached to a GO or a MID, whether words like “and” or “also” need to be inserted into logical places in order to form organic-sounding sentences, and so forth. If, then, we imagine only the first of these being in the journal, you could turn to the latest page of your journal and see…

“I was given some strange clues by the curator…”

But once the second is added, that sentence in your journal then changes to:

“I was given some strange clues by the curator, and I deciphered a riddle which revealed a hidden staircase in a public garden.”

Which then lays the groundwork for the next sentence (which’ll get a “…” until it’s finished – and so on).

With all this in place, a few other things nevertheless still needed to be added. The first of these was some code to trigger the game to move on to a new page – this wasn’t too hard to develop and will be used not just for the journal when the players moving into a new month, but for all books in general when starting a chapter, new section, new heading, and so on. Connected to this, I wanted each month’s accounting of the player’s activity to start on a new page, so as well as the three categories already listed, I need to add a fourth, called MONO, which activates when a new month passes. A month change is a special sentence piece because it encourages the game to look at the one before it in order to understand how the grammar and sentence structure should be corrected, and always starts a new page and a new sentence. It also means if the final sentence for the previous month is not complete, it just gets finished there and then. This all leads to a really pleasing effect which you can see in this really cool gif below (with silly placeholder text!), where each month starts on a fresh page, each month recounts what the player character has been doing in that month:

But that’s still not all – a few other things need to be added to this system as well. One of these was to enable certain sorts of events to automatically trigger an END state, even if the system is not currently in that state. These were for events that are of particular importance, or contains several sentences already, and thus need to always advance the journal to a new line rather than being hidden or caught up as part of an existing paragraph. This was surprisingly tricky to implant because of how the system as created builds these chains of GO, MID and END logic, but I got it done, and that now works for particularly important sentences getting added into the list. Another thing that had to be added in as well was some coding to take account of a month in which the player might not achieve a lot. For instance, if the player knows where they need to go but that place is over 28/29/30/31 map tiles away, they may well spend the entire month simply in travel. Similarly, if the player believes that most important thing or useful thing they can do right now is to wait until a certain moment – a certain month, a certain phase of the moon, etc, even though will consume the character’s finite lifespan – then we need to take account of that as well, even if it takes a full month or even several months. As such, there are now several trackers which keep track of how much time in a month the player waited, and also how much time they spent in travel, without necessarily doing anything else. If either of these is more than 0 for certain month, then the only journal message for that month takes account of it. If it’s not, then a message noting that the player character didn’t really do much in that month is added to the journal for that month instead. That last message I would expect to be quite unlikely, but I think messages of pure travel and pure waiting will become somewhat common. All this goes back to the idea of time as a resource in the player character’s finite life – what’s the most you can discover and uncover in one lifetime?

Then, yet another thing the system I needed to implement was some way of making sure that certain messages which shouldn’t repeat, don’t repeat. For example, you might enter a bioregion or a nation for the first time, but I didn’t want that to keep showing up over and over, because if it does then moving in the area with lots of bioregions would flood the journal, and going back and forth between nations would flood the journal – whether the player was doing that deliberately to sabotage the journal for amusement, otherwise. As such, the journal does not repeatedly note when you move into a new bioregion or move into a new nation, but it does note the very first time you do that. Similarly, if you find a chest as a result of solving a riddle, it will note in the journal the first time you open it, but not other times you open it. Same goes for reading a book for the first time, entering a particular building on the world map for the first time, and so on. My thinking here also is that with time, locations should become a little bit more familiar to the player, and so don’t need to always be noted – although the journal will of course note if you do something new in them. So if you go into a tavern very early in the game it’ll note that, and then you might go in repeatedly later on, but only when you discover a secret within that tavern, will it again be explicitly noted in the journal, whilst all your other repeated entries will not. So the point in other words is this: no repeats, unless there’s novelty involved in the nature of the repeat.

Given all this, here’s the current suite of event types that can appear in the journal (“leave on quest” triggers only at the very start, and plants and fungi and trees are all part of the “fungi” event):

So, with all that done and placeholders implemented for each of these event types so that I can test the system, the only remaining task is to integrate the journal into the game and have it be correctly filled-out with the players in game actions, rather than with placeholders. I debated doing this right away, but I actually want to add significantly more to books before I move all of the book code from the testing program into the main code. This will include, for example, some more snazzy visuals which can appear for title pages, adding adding the possibility for special chapter headings, and all these sorts of things. Even if I won’t be generating the actual content of books – aside from the journal, which is special – until 0.12, with so much of the technical and logical basis for this development already implemented as result of the work over the last few weeks, it just makes total sense to me to finish it all off now, and then literally everything will be ready for me to – next year- simply plug in any kind of text, and any kind of pictures, and have the books spring into life. As such, I’ll be showing off in a later entry the integration of the journal into the game world and the transition of these categories of sentence pieces away from placeholders towards actual things which actually respond to what you’re doing in the game (once I’ve done it, anyway!) – but for now, I think this entry gives a great sense of the journal and how it’s going to work. Most of the hard work has been done in these last few weeks, and I’m really excited to – once I’ve done these other book aspects – transpose it all into the main code and start testing the journal’s hopefully perfect ability to record everything of note a player might be doing within the game world. As with the tutorials in a recent post, I have to I’m finding all of this development at the moment just so exciting, because it’s pure gameplay – it’s solely here to assist the player, help them track knowledge, help them make sense of what they’ve been doing, and plan future decisions. Fantastic!

What next?

Well, I think that pretty much wraps it up for this week. Here’s the journal, here’s how it’s going to work, here’s all the underlying code, and here’s also some of the extra development on books in general done as a result of the journal, such as triggering new pages, working on front pages and headings, and things of this sort as well. Over the next couple of months while working specifically on the 0.11 work I will be taking occasional breaks to further develop the front pages and the other book code, and then like I say, I will chuck it all into the game and develop the code for responding to every possible subcategory of all those event categories which could show up in the journal. Again: I’m really excited by all this. Thank you all so much for reading this post, and as ever please do leave me a comment as I’d love to know your thoughts or reflections on all of this! And also as ever, please do share this around on the web if you think that there’s other people or other communities you know of who would enjoy this kind of dev blog. Thanks so much everyone and I will, once again, see you in two weeks :).

Leave a Reply

Your email address will not be published. Required fields are marked *