This is a big one, I think :).
I normally start each blog post with an update about 0.11’s development status in terms of what is finished, what is being done, what has not yet been started, and so forth, but this week I’m unveiling progress on something so novel and interesting that I’m going to skip that and get straight to the point. At the Roguelike Celebration this week I’m giving a talk about the initial stages in the generation of cryptic riddles in Ultima Ratio Regum, and this blog post is meant as the accompanying part to that talk. Please do come along to the talk if you’re around at the time – I’m really, really happy with the presentation, and I think it really gets across a lot of the key design goals here, as well as some of the understanding code design (which long-term readers here will know I tend not to talk about in much detail). I believe the video will also be uploaded to YouTube at some point after the event, so probably in the next blog post I’ll add a link to the video if it’s live by then.
Anyway – I’m here this week to show off some of the initial stages in the procedural cryptic riddle generation in URR. I stress this is very much in development but I’m incredibly happy with and excited by what we have going so far. Readers will know that a key part of the forthcoming 0.11 release is the implementation of generated and working treasure maps…
…but there’s a lot more of this sort in development. Secrets have always fascinated me in games, and any game where the key objective is to, in a sense, uncover secrets – La-Mulana, The Outer Wilds, things of this sort – have always held a particular place in my heart. Roguelikes don’t generally do a great deal of this, although games like Noita, Caves of Qud, and Spelunky are clear exceptions here through Noita’s extremely cryptic hidden end-game quests and secret interactions between many of the game’s pieces, and Spelunky’s (and Spelunky 2’s) quests entailing the collection of special items, their use in particular locations, and so forth, in order to access hidden endings of hidden areas. However, the riddles in Noita and the Spelunkies can essentially only be solved once – even if they’re challenging. Qud’s “secrets”, however, are by far the closest to what interests me here, given their ability to point the player towards interesting locations. However, one of URR’s core goals is to – in this one specific aspect – go further. A lot further, to the point of this becoming one of the absolute core mechanics, if not the core mechanic.
So without further ado:
Ultima Ratio Regum can now (begin to) generate actual textual riddles, which actually point to real locations in the world map, but do so in a suitably cryptic and multi-layered way. Here’s an example of what one of these might look like, on the new “note” item type:
In this case there are five main components here – “a cold hand” (?), the “gem”, the “bane of Irakor VIII” (presumably some past ruler or monarch?), “below which” (go underground?) and the wall that faces a slum. I talk about how to solve this particular riddle in great detail in my Roguelike Celebration talk, but essentially the player here would need to look around their local area (this is a fairly “easy” intro riddle, perhaps the sort the player would get when they begin a new game?) and use the information they can see about districts, cities, towns, and locations within those places, to figure out what the various components mean and hence what this particular clue note is actually instructing them to do. Once all the information has been acquired, the player might then understand thusly…
…and hence know where to go in order to place a sacred pot and complete the quest! I see the textual riddles as being probably the core and most common part of the puzzle generation in the game, mainly because I just think the capacity of the game (growing with each passing week!) to actually procedurally generate these, and have them be meaningful, is just too damned cool to not do everything with I can possibly think of. The game can also handle various lengths for these clues, and will also sometimes have part of the clue referencing something else, rather than just a synonym or something you can find on the map – and so this is how we then scale difficulty. In the case of “the bane of Irakor VIII”, for example, perhaps you would have to then go and find a biography of this king and discover that he was an avid gambler in order to solve this part of the puzzle. In another riddle, however, maybe there’s a reference to “the sacred thing of the Queen of Dreams” – in which case you need to find that out, but perhaps the holy book of that religion only means that what is sacred to the Queen of Dreams is “the grey animal of the westernmost wastes”, in which case you then need to discover what that is. Or, perhaps, in other set of clues each one gives you one piece of an overall understanding about a sequence of historical figures, where all the clues are required in order to place them in the correct sequence and know what to do.
Through these techniques – adding more components to a riddle, and a greater distance between what you now know, and what you need to know to understand that riddle – we can thus scale these according to difficulty, and ensure that as the game goes on (and the player is gaining more and more information about the generated world) the puzzles are scaling appropriately, requiring more pieces, more connections, and more observation, in order to crack. I can’t quite get over how cool these are – and again, they’re procedurally generated!
These textual riddles I think are fantastic, and will be an absolutely core part of the game – but we can certainly add far more variation than just those. I don’t want every single note to be a riddle of that same type, as that’ll quickly become something that the player gets very used to. A secondary concern here is also that as the game progresses and the player collects more and more notes, we need something else to help the player keep track of which notes are which, which have maybe been solved, and so forth – and so as always in procedural content generation, emphasising difference is a really key objective here. For example, I am also in the process of implementing what I’m thinking of as “letter riddles” rather than “text riddles”, which will have a cryptic selection of letters and sometimes numbers compressed into various blocks, and which – like the textual riddles – might point you towards a certain place, a person, an item, an action, or something else, and which also might need combining with other clues in order to unlock and fully understanding their complete meaning. One of these for example looks something like this:
As for how one actually deciphers this, or figures out what to do with it, I don’t want to go into too much detail here (even knowing that far from all players will ever look back at this exact blog post to figure it out!), but let’s just say that names, titles, and other things of this sort, might be very important for deciphering what these clues are telling you, and where they’re encouraging you to visit…
I’m also working on other clue forms as well! All of these, again, are still in development, but I’m really happy with how some of these other types are also coming along, and the variety they add to what the player can see. I also (as mentioned previously) intend in future versions for the player to simply begin the game with a number of notes (perhaps one of each type?) and these I imagine as being a core part of getting a completely new player intrigued – what are these, and what do these mean?
But yes, we have some other clue forms also beginning to come into being. I wonder what these depict?
And these, too:
Weird. What we can confidently assert, however, is that each of these will be able to be integrated with a whole range of different clues, riddles and puzzles, meaning that even if the player completes one playthrough, they shouldn’t be confident in knowing immediately what these mean on a subsequent playthrough! I’m making sure that understanding the genre of the clue is as much of a challenge as understanding the specific import of a specific clue itself, and this is going to be pretty important for ensuring replayability and ensuring that players don’t end up with clues that are just trivial to solve, but just need solving nevertheless. This kind of (early game) repetition in roguelikes can be a real killer, so this is something I’m extremely keen to avoid.
And who knows, maybe there are some other categories of clues that I haven’t even shown off here at all yet…?
Writings on the wall
I’ve also started implementing the ability for the game to generate inscriptions on walls and floors, and to have them only show up when you look at the appropriate area within the game world. Given that the entire game world has 2.5 billion potential tiles – if the player actually went around and generated every single map tile, although the true number would be lower than this due to water, which you cannot currently sail around on independently of taking a ship from a dock – there’s no real way to just randomly search for these, and so the player will have to be told where to look. This might be something like “the eastern wall behind the eastern-most statue in the vestry of the northernmost hermitage” (as in the gif below), or perhaps “the floor by the bed of the head of House Arthin”, or “the road three paces north of the entrance of the Monastery of the Quiet Voices” – or whatever it might be. When you take a look at any tile without anything to say it just shows the usual terrain look-up, but when you look at the exact location where there is something to see…
Which would probably never have been found if you hadn’t been directed to it by another clue! The colour of the engraving of course adjusts based on the terrain you’re looking at which contains the engraving, in order to make sure it’s always pretty easy on the eyes. The system for generating these and making sure they are always accurately placed given the text of the clue is now well along in its development, and looking really exciting. As a side note, one of the interesting parts of generating these was making a set of potential letters that could either be directly on the ANSI characters already placed, or 50% offset. What I mean by this is shown in this debugging diagram here (or in the above by looking at how there are two versions of each letter, such as the ‘s’ in ‘saint’ and the ‘s’ in ‘nourishment’) –
– where you will note we have two copies of each letter. The first copy each time starts directly on the character, and the next one starts half a character indented. This was necessary because putting no gap between letters meant one sometimes couldn’t really distinguish letters as well as one would like, and having a full character gap between letters made it much harder to read. Instead, the game alternates from letter to letter picking a letter that starts and ends directly on the grid (e.g. the first “A”) or starts and ends half way across the grid (e.g. the second “Y”). You’ll note that some letters are very easy to reproduce in both of these forms, but some of them – ‘A’ and ‘G’ particularly stand out – were very tough to produce with the 50%-offset version.
Anyway, once the game knows what the text is it then splits it into lines by counting up the exact size of each letter and the spaces required on each line, and then has to calculate the size of each line, keeping in mind that the letters will alternate between those which start with a full character and those which start with a half-character. It then centres the lines and prints the appropriate sets of letters, again alternating between the two “typesets”, until the message is complete. A little bit of remaining code is still needed here to ensure that these wall / floor messages are not too long to be put in here, nor that they use any words which are too long to fit into a single line with this writing style (very few words would qualify here, but some would, and the game needs to be able to handle those).
I’m also working on a few variations…
…but they aren’t quite ready yet, and need a bit more work to ensure the colour balance and so forth is correct :). Nevertheless, the ability to now hide these written clues on essentially any tile of the map, and have other clues point and direct the player to those tiles, is really exciting! So many possibilities for hidden messages and puzzles, last words from dying warriors, and anything else I (or you! Post ideas below!) can think of, really…
And – my goodness! We also now have the beginnings of book generation! Or rather, book presentation, anyway. I haven’t yet begun really generating the content in earnest, so for the Roguelike Celebration talk I took the important part of the generated clues and added some non-generated text around them to give a good placeholder impression of what the final generated text will look like. What I have worked on, however, is the actual visuals and mechanics of opening and flicking through a book, and I’ve got to say I think these look absolutely gorgeous, and really exciting (this is a gif with a long pause at the end, so make sure to watch the whole thing!):
Firstly we see the title page, which will of course be generated in terms of the writing there, the use of those flourishes to separate parts of the title, the presence of a publication date (not relevant here in a holy book, but will appear in all the commercially produced in-game books, and again might be part of a clue), and then the higher-quality books will have a little bit of colour ink, such as the banners of berries or red leaves shown here in this example. Again the nature of the banners and the graphics will be generated, and I certainly intend for the possibility of having pages later on which are entirely graphical – or which have a small graphic perhaps showing a symbol, a place, a part of a map, and the like, alongside what is otherwise entirely text – alongside pure text pages. I did a lot of experimentation with visuals and colours and spacing of the text and this mode, where each sentence has a gap between it but the individual lines of the sentences are together, and then a paragraph will have a line or some little squiggle to separate it from the next one, actually works really well and is pretty easy on the eye in-game.
Books will, of course, be a core place where clues and hints can be found, but what I think is really important is that the game shouldn’t be explicitly telling the player that there’s something here to followed up on, i.e. that something in this text is highlighted, or enters a “quest log”, or something of this sort. Rather, it’s more exciting that everything mentioned in books can be followed up on. Every time the player reads something in a book referencing something specific, I want the player to be able to think “hmm, I wonder whether…” and to, sure enough, be able to find or hunt down more information, and potentially something valuable, from whatever’s being talked about. The ways to do this are obvious for things like history books and biographies, but will also have clear functioning for other sorts of books too, like novels and philosophy books. In the first case novels might be “based on true events”, for example, or contain hints to concepts or themes that other clues then reference; philosophy books will by contrast be important for understanding how a certain people think about things, people, objects, history, and so forth, and these different understandings might be reflected in, and important to understand if one wants to make sense of, other clues. In the case of this holy book, however, we see these two paragraphs where the book describes two saints in this religion who did a particular pilgrimage, leaving holy pots in the locations they visited, and that someone who follows in their footsteps would be rewarded:
I have been working on how it presents and looks to the player using this text, and honestly I’m unbelievably happy with how it’s looking. I love how that gif shows the player opening the cover, seeing the cover page, and then going through the pages the book has to offer. Of course, depending on the length of the book, the visual of the compressed papers at the bottom of the paper will slowly shrink until you get to the very last page. But yes, the presentation element of book text is now pretty well implemented, even while the titanic task of fully generating the content is not one I’m doing for 0.11, as it’s probably going to be essentially a full release by itself (maybe 0.11?). Nevertheless, the code for generating the clue component that needs to be inserted into a book is coming together, and the look of the books is really exciting too. More on this to come in some later entry, I’m sure :).
That’s a lot of procedurally generated riddle stuff to show off (and what I’ve shown here is only the start of what I have planned, but let’s not get ahead of ourselves…).
Almost lastly for this fortnight’s update, however, is the announcement:
A new version of URR is out! As ever, you can download it here.
This contains a fair bit of what I’ve been posting here on the blog since the 0.10.0 release – though some features are not totally finished, or not fully bug-tested, so have been temporarily held back until the much bigger 0.11, or perhaps a 0.10.3 if that ends up coming into being – and a tremendous number of bug-fixes and polishes, easily in the hundreds. Many of these I’ve posted about in the previous 0.11 dev updates. Here are some screenshots!
Finally, as part of this interim release, there has been a further…
MASSIVE AMOUNT OF BUGFIXING
- Fixed a bug with the text in the bookmarking window not always appearing until the player had moved their cursor around the bookmark window a little bit.
- Fixed an issue with calculating the range of how far an NPC should “look” when discussing questions like “are there any [whatevers] nearby?” sometimes causing a crash.
- Fixed a few minor graphical issues in some of the guidebook entries.
- The canteen management window is now rather clearer and nicer to navigate, and looks like it fits more fully into the rest of the game’s general menu / window aesthetic.
- Bookmarks on map tiles now appear correctly in the “Load Game” menu.
- Fixed a crash when you ask someone about the quality of their armour or their weapons – this actually needs some much more detailed code when combat is implemented, but for now, the NPC just gives a sensible response and the game doesn’t implode.
- Inverted the light and dark colours on turbans, thereby making them look far cooler.
- Fixed a bug where around 1/5th of civilizations did not select an interior for their castle courtyard, which meant generating the outside of the castle would then crash when trying to figure out what shape should be in the middle.
- Guards outside mansions no longer very rarely decide to protect the building while completely naked, rather than wearing armour and the like.
- Fixed a bunch of typos in generating the names of history books.
- Improved the bookmark functionality a little in terms of how usable it is (but this needs further improving still).
- Fixed a long-running but extremely rare and strange bug involving assigning nations to the embassies in a country’s city centre, which around 1/200 times caused world gen to crash. I actually still don’t perfectly understand the cause – as the code I replaced was some weird old code I clearly wrote in a fit of derangement, and which no longer makes any sense – but the bug seems to be fixed either way.
- An ‘enter’ keypress can no longer carry over from starting a game into the screen where you select your starting civ, and hence prevent the player from making those choices.
- Being on foot outside a city gate, using the travel menu to try to go in, changing your mind, and then reloading the same map grid, no longer causes a crash.
- When you use the ‘@’ button to look at yourself, you no longer need to press Escape twice (instead of once, which it should be) in order to return to the game.
- The sidebar no longer mysteriously flashes once on-and-off when you load a game and you take your first move in the loaded world.
- Improved the shading on and significantly reduced the amount of time it takes to draw religious vestments and nomadic robes / shoes (tribal garments still look a little bit dodgy, but I’ll get to those next).
- A small number of walking canes no longer cause the game to crash when you look at them.
- Looking at certain things in the encyclopedia no longer has a few formatting errors, particularly placing things like “??????” in places where information should actually be.
- Religious buildings now correctly spawn religious symbol statues on the outside, giving the player a fast way to figure out what religious building is what (faster than going inside).
- Adding a bookmark on certain locations no longer causes the generation of roads on that location to become weirdly screwed up.
- Bottles of alcohol no longer erroneously sometimes say “it is empty” when you examine them despite the bottle being, clearly, full of drink.
- I have removed “General Stores” from markets, towns, etc – over time it’s just going to be annoying feeling one “has” to check it for useful items that might not be in a local specialist shop, so now just specialist shops exist so that you know only one shop is going to contain item X, rather than potentially two.
- Fixed a minor visual bug with some of the information and description from the travel screen being left-over when the player was no looking travelling, but only looking at the world map.
- Resolved a few minor graphical issues in the canteen management screen.
- You can no longer sometimes – on the travel screen – exit a city through its walls. I cannot believe that this bug still existed, even if (I now discover) it is only there under an extremely small number of conditions.
- The “Loading” word no longer sometimes appears in strange places around the screen.
- Roads can no longer go across chasms in the ice without properly generating a bridge (and instead just generating some horrible visual errors). Making bridges is a reasonably hefty coding task (the “bridges” in towns and cities that go over rivers are currently just road terrain with no actual water underneath, but don’t tell anyone) but it’s extremely non-essential right now, so I’ve just disabled the ability for roads to go over chasms, and it’ll find its way back in a bit later when I properly develop bridges (this will probably be around the same time that water gains a depth parameter and the player can swim, dive, etc).
- Using the “Options” menu to change the font size of the game window no longer causes some truly horrendous graphical bugs, especially on the sidebar.
- The game no longer insta-crashes when trying to enter tribal encampments (whoops!).
- Dealt with a crash where trying to generate a proper pantheon in world generation for a polytheistic god sometimes can’t find enough “elements” to assign them to the chosen number of gods.
- Fixed a bug with graves sometimes not displaying any name at all.
- Fixed a bug where looking at a well from above or below it (i.e. a higher or lower z level) would have a placeholder character instead of the correct character.
- You can no longer press ‘f’ to fall when climbing on something, and fall safely into lava, water, an abyss tile, and so on.
- Fixed very rare crash bug in religious districts, with worshippers trying to path their way to religious buildings that didn’t exist, and if they did exist, would be outside the map.
- Long civilization names now appear correctly, I think, in all parts of the encyclopedia (i.e. across multiple lines if need be, or adding a “…” to the end) rather than sometimes flowing over the edge of the screen.
- Resolved a long-running major bug causing permanent freezes in religious buildings, from NPCs being spawned in locations from which they couldn’t work out what to do.
- Clothes no longer sometimes look very strange indeed.
- Currencies you hold but have 0 of are correctly removed from your inventory now after spending them (in shops, in currency exchanges, to book passage on ships, purchasing supplies, etc) rather than remaining as a strange ethereal item consisting of 0 coins yet being something you can drop, throw, and so on.
- The game no longer keeps saying “You have not recovered from [whatever ailment]” over and over every single turn under certain conditions, and the desert-related and ice-related ailments are much clearer in how they function.
- You can now, once more, actually, er, sell items. Let’s not talk too much about why this was temporarily not the case. Whoops.
- Fixed a freeze bug where entering a particular rare subset of upper class housing in upper class housing districts would generate an interior where the NPCs present (servants, slaves, whoever) couldn’t correctly path their way around the inside.
- Fixed another, associated bug, with the interiors of these structures sometimes generating without all the required pieces in them, which could also cause a freeze bug under rare circumstances.
- The game can no longer incorrectly think that a diaspora from another nation in a town is a category of shop (like “bowyer” or “jeweler” an so on) and spawn a mysterious “diaspora shop” that contains nothing and can sometimes crash the game.
- Relatedly, towns can no longer spawn duplicates of shops, resulting in one of each version having no merchant, and its items being inaccessible.
- The characters on water very rarely change between ‘~’ and ‘=’ over time, as well as the colours changing – this gives a slightly better impression of change, flow, etc.
- Fixed a major and long-running crash bug where buying too many items simultaneously would result in the game collapsing while trying to simultaneously furnish the player with their items, and restock the shop.
- Digging a hole on a tile with a flower (or, soon, a fungus / mushroom) no longer has the tile maintaining the colour of the plant / mushroom after the hole is dug, and thereby looking rather weird.
- Trying to destroy one of the few items you cannot destroy by just selecting the “destroy” action – ingots, chests, currency, other physically resilient things of this sort – no longer makes the inventory go a bit weird.
- Phases of the moon now correctly advance, and “reset” to the full moon after a complete cycle. Each phase (of eight in total) lasts four days, so this is slightly more regular than in the real world, but infinitely more understandable and easily usable.
- Mesas can no longer appear on road tiles, and thus no longer cause some extremely disagreeable strangeness when the player actually steps onto the map tile.
- Improved a number of “while” loops in world generation that could, in extremely rare circumstances, lead to the game freezing and being unable to continue.
- “You leave the building” now actually appears on the turn when you leave a building (remarkably enough), rather than a turn after.
- Fixed the excellent typo “a group of farms walk past you”, which as my playtester rightly identified, would be impressive.
- Bookmarks appear correctly in the city viewer, as well as on the travel map.
- Significantly improved the visual flair on normal clothing items in feudal / sedentary nations.
- Fixed a long-running bug involving how vision and field of view are handled within buildings resulting in the player sometimes being able to see tiles that are surprisingly distant from them – this no longer happens.
- Messages now save and reload when you return to a world, rather than the message window being wiped clean.
Enjoy! (But as ever, please do report any bugs, especially crash / freeze bugs – I can’t stress how valuable this is to me.)
Well, I’d come back in a couple of weeks when I’ll have another development update for 0.11! And as ever, if you enjoyed this post, please do think about sharing it around online, as I love writing these but they sure to take a solid block of time to actually put together.
Thanks everyone! 🙂