Showing posts with label Game Worlds. Show all posts
Showing posts with label Game Worlds. Show all posts

Wednesday, 21 April 2021

Death, Glory, and computer games

the rookie, quick

Let's suppose for a moment that you're a member -- the most junior member, the rookie -- of a squad. Your squad may be police, it may be corporate security, it may be a criminal gang; this doesn't matter. What does matter is that it exists in an environment in which all these things exist, and compete; in which they compete using lethal force.

As the rookie, you've been issued with a weapon. It isn't a very good weapon; it's old, worn out, not particularly powerful; and you're not yet very skilled in its use. But this doesn't matter; there are half a dozen other folk in your squad who are all more experienced and better armed than you. Your leader is a very experienced -- famous, perhaps notorious -- combat veteran. You feel safe, and your squad is moderately successful.

the killer in the dark

Then, one dark night, within the space of about five minutes, your comrades are picked off one by one by an unknown assailant using a sniper rifle from cover. Most of them never see him; most of them don't get a single shot off on target.

And now they're all -- all your experienced, well armed, competent comrades -- dead. Every one of them, dead. There's only you left. There's nothing in particular to defend. No harmless civilians depending on your protection, no pass that must not be sold, not even any very significant amount of booty.

Carnage

In those circumstances, what do you, the last survivor, the poorly armed rookie, do?

Do you hide, in the dark, in an environment that is full of hiding places? Do you flee into the complex maze of streets and alleys around you, or in one of the fast getaway cars that your squad so often has parked around the scenes of such encounters? Do you stay alive at all costs, to inform your superiors, the rest of your faction, of what has happened, of this new threat they face? Do you throw down your weapon, put your hands up, and beg for mercy?

Or do you fight, to certain death, against a warrior you already know is far more deadly -- and far better armed -- than you are?

Seriously?
the rookie, dead

And yet, this is what (almost) all such characters in (almost) all video games do.

The game I playing at present is Cyberpunk, so the game I am ranting about at present is Cyberpunk. But that's unfair, because this behaviour is ubiquitous. The very rare exceptions (and as far as I'm aware, outside the 'Beat on the Brat' boxing competition, there are none in Cyberpunk) are specifically scripted individual events. The default behaviour for all opponent NPCs is to fight to the death, to fight without quarter given, to the very last man or, all too often, woman.

In Cyberpunk, enemies who are hunting you (yes, even that poor unfortunate last rookie) will call out "come out with your hands in the air," "we only want to talk to you," or "I promise not to kill you."

These apparent offers of quarter are in fact insincere. You are given no way to respond to them directly; but if you do put your weapons down and just stand there, you will be killed. Equally, you are given no way to call on your victims to surrender, or to offer them quarter.

True, you, the player, can walk away from a fight, and (usually) the enemy won't pursue you very far. But, while you remain in the area in which the fight broke out, any leftover survivors will continue, suicidally, to attack.

And surely -- surely -- it can't just be for me that this universal, this irrational, this suicidal refusal either to surrender or to flee wrenches at the willing suspension of disbelief?

A digression: 'non-lethal' weapons

Of course, also, in Cyberpunk, you can use 'non lethal' weapons. 'Non lethal' weapons include most or all blunt melee weapons -- clubs, batons, et cetera -- but also include firearms to which you have added a modifier called 'Pax' which somehow, magically, renders the firearms 'non lethal'.

You can probably guess from all the scare-quotes that I consider this a moral cop-out, and it is. Anyone with experience in the real world knows that blows with a blunt instrument sufficiently forceful to knock the victim out for a substantial time have a substantial chance of causing permanent brain injury or death. Anyone with experience in the real world knows that rubber bullets or plastic baton rounds fired from firearms frequently cause permanent injury or death.

A character sufficiently injured with a 'non-lethal' weapon falls immediately to the ground and never, no matter how long you wait, recovers in any way. Characters felled in this way with 'non-lethal' weapons never reappear in the game.

There are a series of missions given you by a fixer called Regina Jones in which she urges you to use non-lethal weapons, and says that a medical team will come to recover the victim for treatment; but, no matter how long you wait, that medical team is never seen to arrive.

In practice I think 'non-lethal' weapons are just a flimsy screen behind which CD Projekt can claim "well, you don't have to kill hundreds of people, you can use 'non lethal' weapons." But, in fact, to complete a playthrough of Cyberpunk -- even just the 'main plot' quests -- you do have to permanently incapacitate many tens, probably hundreds of characters. In practice, 'non lethal' weapons are a difference that makes no difference.

The reason for 'No Surrender'

So, why? Why does the rookie with the most basic, most useless weapon, sole survivor of his or her squad, still charge into battle against an opponent who has clearly demonstrated martial superiority? Why does the rookie continue to attack even when wounded?

It's partly down to something I've been arguing for ten years now. Because every interaction in modern video games has to be voice acted, characters have very limited vocal repertoire. So there isn't sufficient repertoire for negotiations of surrender (either way). But to an extent the repeated calls of "come out with your hands in the air" give the lie even to this suggestion. There is not just one voice acted instance of that call, there are several. True, they do become repetitive; true, they are not individually voice acted for each opponent.

But the very fact that they are not indicates that it would be possible for the developers to record a few variants of "I give up," "I've had enough," "I surrender." There's an animation which civilian non-player characters caught in the middle of a firefight; the crouch in the open with their hands above their heads. A defeated opponent could put his or her weapon down, call out "I surrender," and do the same.

An injured opponent could writhe on the ground, crying out in pain or whimpering, and beg for medical help. An uninjured opponent could just run away, either abandoning their weapon or taking it with them.

In any of these cases the player would have moral choices. They could succour the wounded. They could handcuff wanted criminals and tag them for the police to collect. They could let fugitives go. Or, they could leave the wounded in agony, could demand bribes from wanted criminals for not calling the police. Or, they could just kill the defeated. In any of these options, the player could either collect the victims' weapons (and, optionally, other valuables) for resale, or not do so.

And, of course, if the player leaves the victim free with their weapon, then there should be at least some chance that the victim will then break their implied parole and restart the fight.

But it's a role playing game. The player should have scope to play their role, to make moral choices. Some players will choose to be merciful; some, even, quixotic. Those choices should be there.

Not providing these options -- having every non-player opponent continue to fight, obstinately, mechanically, robotically, to the bitter end, to the death of every last member of the squad, without ever considering or trying or begging for other outcomes -- is lazy. It's not good game design. It rends at the willing suspension of disbelief. It sucks.

Friday, 1 January 2021

T-Bug, memory management, and Cyberpunk

A Cyberpunk 2077 character in T pose
I have no inside information about the development of Cyberpunk 2077, but I am a software engineer with 35 years of experience, and I have written mods for both CD Projekt and Bioware games.

Cyberpunk is essentially two products: RED Engine, and Cyberpunk itself, which runs on top of Red Engine. The engine is very much analogous to a JVM: it abstracts the platform for the game code that runs on top of it.

The Cyberpunk layer itself, and the graphical and audio assets, are probably identical between PC, and old and new versions of the XBox and PlayStation platforms. It is the engine that differs between the platforms. The Cyberpunk layer seems to me to be in a good state of completion — there are bugs, but they're relatively minor.

The version of RED Engine used for Cyberpunk is surprisingly little changed from the version used for Witcher 3, CD Projekt's previous major game. The main obvious change is improved background loading of assets. On a PC towards the upper end of recommended spec, this too is reasonably solid: I have had one crash, one significant audio glitch, and two or three minor visual glitches in twenty hours of game play.

But it's clearly in the engine that the problems lie, and is, I think, where the problems have always been.

The game was launched simultaneously on PC, and on both 'last gen' and 'next gen' XBox and PlayStation consoles, although on both XBox and PlayStation, the code at release used the 'last gen' APIs, and next gen consoles run this in their respective backwards compatibility modes. A further release using next gen APIs is promised, but is not yet available. 

However, the game runs reasonably well on modern gaming PCs and on next generation consoles. But it runs extremely poorly on last generation consoles, to the extent of causing a great deal of negative comment. So why? What's going wrong? 

I emphasise again: I don't know, I have no inside information. This essay is reasonably well informed speculation, and nothing more. However, this is my opinion. 

What sets the older XBox and PlayStation platforms apart is that they have much more limited i/o speed, and much more limited main memory, than the newer generation (or than current PCs). They also have slower processors and more limited graphics subsystems.

Night City — the setting for Cyberpunk — is an extraordinarily ambitious and complex visual environment. To render a single static scene, hundreds of models and textures must be loaded from backing store. 

But the scenes are not static. On the contrary, the user can look around freely at all times, and can move quickly through the environment. At the same time, dozens on non-player characters, vehicles, aircraft and other mobile game objects are also moving (some rapidly) through the scene.

From a development and testing point of view, it's easy to test that a given asset can be loaded into memory and rendered in a given time. It's even relatively easy to test whether a given set of assets can be loaded in a given time.

But what I have particularly seen in the videos of the game running on old-generation hardware iis
  1. Late loading of higher resolution textures; and
  2. Assets (particularly non-player characters) being rendered in default poses.
I also hear that there are a lot of crashes, which I'll come back to.

The two issues I've described above both seem down to the program being i/o bound — it can't get data from disk to screen fast enough, because of limitations in bandwidth. That's hard physics: yes, you can work to make the graphics selection and loading code as efficient as possible, but if you need all those bits on the screen to render a scene and the system doesn't have the raw bandwidth, it isn't going to happen.

The problem is made worse by limited main memory. Where there is main memory to spare, it can be used to cache near-screen assets, so that if, for example, the player turns their head, the required assets are already in main memory. But if main memory is exhausted with all the assets currently on screen, then when the player turns their head, unwanted assets must be culled and fresh assets loaded, immediately.

This raises the issue of crashing. These game assets are big. Culling and reloading will rapidly fragment the heap. But pauses for garbage collection are really undesirable in a fast moving real time environment. Near real time GC of rapidly fragmenting heaps is hard.

Worse is, I suspect, what happens when/if the assets required to render a scene in themselves exhaust main memory. I'm pretty sure this happens, because it's noticeable that scenes rendered on old generation consoles contain fewer non-player characters than similar scenes rendered on PC. There's clearly code that decides whether to cull non plot critical non-player characters when memory load is high.

But thrashing is likely to occur — or at least, there will be need for sophisticated code to prevent thrashing — when assets required to render a scene cannot be accommodated without removing other assets also required to render the exact same scene.

This sort of code — especially when it is being developed under pressure — is very susceptible to the sort of bugs which cause crashes.

So, from a quality point of view, where does that leave us? All these aspects of engine performance are suitable for unit tests, integration tests and characterisation tests. Characterisation tests – does this code run exactly the same as that code? – may be particularly relevant when testing ports to multiple platforms.
 
If there is not a comprehensive test suite and a continuous integration platform then someone is very derelict in their duty, and I do not believe that. CD Projekt strike me, in both artistic and technical proficiency, as pretty thorough.

Furthermore, we've seen very impressive renderings of scenery and action for two years now, so the upper bound to the size and numbers of assets required for scenes has been known for at least that time. So the performance and stability problems on old generation consoles must have been known.

That implies to me that management ought to have said, at least a year ago, "we will launch only on PC and next-gen platforms, and a degraded version for old generation consoles may follow later but we don't know when."

Obviously, investors and owners of older consoles would have been disappointed, but it would have avoided a significant hit to reputation.
 
This essay started as a comment on a YouTube video, which, if you're interested, you should watch. 

 

Thursday, 17 December 2020

Cyberpunk 2077, considered as a Witcher III DLC

Johnny, Panam, Vixen
This is the first essay I've written on Cyberpunk 2077; I doubt it will be the last – indeed, I hope it won't, because if it is that will mean the game has failed for me. I'm currently fifteen hours in, and, at this moment, I have to say that it's on it's way towards failing. And the question you may well ask, is 'why?'

Well, essentially, because, rather than being a wholly new game, this is, essentially, an add-on pack or downloadable content for The Witcher III. It uses the same engine, but far more than that, it uses the same mechanics and the same structure. And the mechanics which were excellently tuned for the wide open spaces of Velen or the relatively small urban environments of Oxenfurt anf Novigrad do not work well in a sprawling metropolis like Night City.

Traversing the space

You can, of course, walk everywhere. It's possible. This is made more bearable by the fact that there really are a lot of interesting people – non-player-characters – on the streets, and that, although the same models do get reused, there are sufficient of them that it rarely becomes too obvious. And the architecture truly is epic; it's a great city for sight-seeing. But the distances are very considerable.

In the Witcher III there was one 'point of interest' every two minutes or so of walking time. That lead to some absurdities, of course, such as inhabited villages existing within a couple of hundred metres of the lair of a monster which is a challenging fight for an experienced witcher. In Night City, too, civilian life carries on within very short distances of acts of gross violence, but the points of interest in Night City are very much sparser than in Velen.

In any case the scenery of the Witcher III is just so gobsmackingly beautiful that it's a pleasure for me to be in, even if doing nothing. Riding slowly right across Velen from the Nilfgardian camp in the south east to the Pontar delta in the north west, on a quiet evening, for no particulat purpose, is a joy in itself.

I'm sure there will be some people for whom the cityscape of Night City will have an equal attraction; even I, a rural person, do enjoy it. But it's a much more difficult landscape to navigate, because there are few long views, and many routes which look obvious on the map are in fact blocked by structures.

But, given the sparsity of points of interest and the overall size of the map, if you walk, you're going to do an awful lot of just walking.

Of course, you're not expected to just walk. You're expected to drive. But there are no cars in the Witcher III; the mechanic simply isn't there. Consequently, to implement cars in Cyberpunk, CD Projekt took the boat code from the Witcher III and repurposed it. Cars in Cyberpunk use exactly the same controls as boats in Witcher III, and behave in exactly the same way, at least if you're using a keyboard; with just one important difference.

The helm on the Witcher III's boats has three positions: hard over to port, dead centre, and hard over to starboard. Similarly, the steering on Cyberpunk cars has three positions: full lock left, straight ahead, and full lock right. The Witcher III's boats have two speeds, slow for navigating close to hazards, and somewhat faster when covering long distances. And this, though not a good model of sailing boat physics, works well enough in marine environments which have few obstacles and no pedestrians.

Cyberpunk's cars have three settings for speed, too: full acceleration, gently deceleration, full brakes. 

The accelerator, the brake, and the steering on cars are analogue controls. They're analogue controls for a very good reason. Cars operate in complex environments with many obstacles: pedestrians, kerbs, other cars, barriers and so on.

Computerised control systems can do very precise navigation of quadcopters which have motors which can only be on or off, by using what is called pulse-width modulation; that is, essentially, they spam the on-off switch of the motor very rapidly so that it's on for just sufficient a proportion of the time to output the power that would be output by an appropriately set analogue conteol. Similarly, it is at least theoretically possible that someone with enough patience, dedication, manual dexterity and tolerance of repetitive strain injury could learn to rattle the W, A, S and D keys sufficiently rapidly and sufficiently precisely to emulate analogue control of a Cyberpunk car; but if you're a mere mortal, forget it. The cars are undrivable.

Of course it's possible that a game controller will do this better; most game controllers have at least two analogue sticks, and I'd hope that this is sufficiently well handled that with a controller you do actually get analogue control of speed and steering. If that is so, the cars will be drivable, and the whole game will be a different experience. But if that is so, CD Projekt should really have said "this game is not playable with keyboard and mouse, you must use a controller".

Here in the real world, in 2020, Tesla's cars can follow a lane, and can avoid hitting obstacles in front of them, without any input from the driver. In Witcher III, horses, like Teslas, won't ram themselves into solid obstacles or leap over cliffs, although they will mow down pedestrians without a second thought. You may reasonably ask why CD Projekt based Cyberpunk cars on Witcher III boats rather than on Witcher III horses. I don't know; it would have seemed an obviously better solution, but for some reason they didn't.

While we're on this, just as Cyberpunk's cars are essentially Witcher III's boats, so the rapid travel stations are essentiallyjust  Witcher III signposts. I believe that Night City's monorail system – NCART – was in fact pretty much  fully implemented – we saw it in action in one of the early trailers – and it would have made a much less immersion-breaking way to get around; but it's been pulled from the final game. In my opinion that's a shame.

I should confess that I haven't actually used rapid travel, just as I don't in The Witcher III. It's immersion-breaking, and I just prefer not to.

Story and Characters

Game mechanics are not what a CD Projekt game is all about; it is, or should be, all about character and story. I only raise mechanics at such length here because they are so intrusive that they make getting to the story unreasonably difficult.

But even in character and story, my first fifteen hours have been underwhelming. Interesting, likeable characters have been introduced – and then killed off. Not because some failure of mine got them killed, but because their death is required by the game. Of your three companions in the critical early-plot quest 'The Heist', one inevitably dies; one, in my play-through, has disappeared and I do not know whether they will have any further part in the game; and one (also, it seems, inevitably) double-crossed and attempted to murder me – so it's unlikely we're going to be friends again.

The client on whose behalf the four of us were carrying out this quest has also disappeared, and although I suspect this will probably not prove permanent, she isn't around just now.

Great, startling, unexpected events have unfolded – have unfolded literally right in front of my eyes – but it does not seem to me that any actions or choices of mine had any impact on those events. At this stage, the main plot feels like a juggernaut, carving an unalterable pre-determined course through the world, unresponsive to anything I do.

So I'm left with, as characters I'm interested in, Victor Vector, a cheerful, friendly and well intentioned ripper doc; Misty, a slightly mystic-meg-new-age-hippy-fae tarot reading shopkeeper who is Vector's landlord; the obviously bright but equally obviously vulnerable and damaged Judy, and... yes, that's about it. And I don't – yet – know any of these characters well.

Of course I've met Johnny Silverhand, and through his memories I've sort-of met Kerry Eurodyne; I've met Rogue, both in Johnny's memories and in my own explorations; I've met T-Bug, but I've no idea whether she plays any further part of the story (I'll be disappointed but not surprised if she doesn't); I've met Panam, who I know from trailers will become important; I've met Clare, the bartender from Afterlife; I've met Jackie's mother Mama Welles; I've met Meredith Stout...

I've added a wee extra piece about Meredith Stout and the other romanceable characters at the end of this essay, since to say what I need to say about her involves spoilers.

Combat and Tactics

One plays role-playing games to play a role. The role I'm playing is a girl I call Vixen. She's small and not strong, so, contrary to Night City's brash style, she usually dresses simply and inconspicuously; she uses persuasion where she can, and tech and stealth where that doesn't work. Where stealth fails, she uses a sword for (relative) quietness. She has a clear moral code, or at least one that seems clear to her.

At least, that was the plan. In practice, it mostly hasn't worked. The tech skills so far have not felt engaging or especially useful – I've disabled a lot of security cameras, but mostly too late to be useful; and I've distracted a few enemies by hacking things in the environment. But the modal nature of scanning makes it artificial and not very free-flowing, and the decode minigame is just a nuisance.

Stealth is also underwhelming. I've put a lot of my skill and perk points into stealth, and I work hard at staying low and keeping out of sight. But it rarely gets you where you need to get to, and usually you end up in a fire fight.

In the early game, the Black Unicorn blade – which you get as a bonus if you bought both The Witcher III and Cyberpunk from CD Projekt's own online game store, GOG.com – is a really effective weapon, so that, in fact, you can take a sword to a gunfight and have a real chance of winning; however, with the first person view, sword play doesn't really work. You don't have good tactical awareness; when your oponent isn't in your relatively limited field of view, it's hard to know where, and how close, they are. Having said that, you can get quite a long way by just rushing around the fight scene in a random fashion slashing wildly all the time. This, with regular use of the health-boosting inhaler, is reasonably effective even when you're up against half a dozen goons with assault rifles. But this isn't role play. It feels wrong.

While on this, I normally have Vixen wear full length jeans and a very high grade bullet proof vest. She's understated because she doesn't want to attract attention, because she wants to be underestimated by any attention she does attract. But I have aquired along the way a skimpy sequinned crop-top and a pair of vestigial shorts which actually have higher armour statistics than those. Again, it makes no sense; it perturbs the willing suspension of disbelief.

The 'health inhaler' is, of course, your Witcher swallow potion. One of the benefits of the 700 or so years which have passed between the action of Witcher III and of Cyberpunk is that swallow no longer has cumulative toxicity, so you can use it frequently during a fight (provided you have enough of it, and I never ran out) to soak up ludicrous amounts of damage.

Finally, there are bugs. There are not nearly as many bugs (at least on PC) as some commercial revieweers have suggested, but there are a few that are plot breaking; there is no solution other than going back to a previous save, and doing something entirely different. You can't abort what you were doing, go and do something else to gain more experience and skills, and come back later.

I've seen one non-player character in a 'T' pose. Some of the tarot card murals that I'm supposed to see aren't visible to me, although the game checks them off to say I've seen them. On a couple of occasions, the audio of dialogue ran hugely behind the animation and subtitles. This is not bad for a just-released game; of course it isn't perfect.

Conclusion

In conclusion, bear in mind that I'm not really the target audience for this game; I'm not a great fan of cyberpunk as a genre, the present is easily a dark enough future for me. I don't like guns. I don't like killing people even if they 'deserve' it; I'd much prefer to settle conflict by negotiation. The poverty of non-player character repertoire in modern video games, as I've written ad nauseam, really disappoints me, because I really feel we now have the technology to do so much better.

I bought into this game because I have faith in CD Projekt as story tellers. And I do think there is great story here – there's certainly the potential for it. But at this present moment, after fifteen hours of play, I'm not really getting enough story reward to compensate for all the awkward, clunky mechanics. I am not talking about bugs here –as I've acknowledged, there are bugs, but none I've seen is significant. The problem is not in bugs, but in intended features which just don't work well.

Again, the main problem I'm talking about is the cars. It may be that, with a controller, the problem doesn't arise. I mean to find out. After all, there is plenty of video – not only in CD Projekt's trailers – of people driving around Night City reasonably smoothly. But it really wouldn't be rocket science for CD Projekt to 'Teslaise' the cars in a future update, so as to give them intelligent lane following and collision avoidance. If they did that, this would become a good game.


Here be Spoilers: Romance in Night City

OK, spoiler time. If you don't want spoilers read no further.

Right, you're sure you want to read on?

A CD Projekt game would not be a CD Projekt game without sexual relationships. In the trailers CD Projekt strongly hinted at who the romanceable characters –– the love interests –– would be.

Judy is definitely one, and she's the one I'm most interested to explore. But Meredith Stout, the hard as nails corporate agent, was clearly trailed as another. It turns out – how can I put this politely? – she's a slightly updated version of a Witcher I sex card. As relationships go, I've seen deeper and more meaningful puddles of vomit. That's five minutes of my life (because I swear it wasn't longer) that I shan't get back again.

For the rest, my guesses (these are guesses, not knowledge) are that 

  • Victor Vector is romancable if you're playing a straight woman, and possibly also if you're playing a gay or bi man;
  • Kerry Eurodyne is romanceable in all cases;
  • Panam is romanceable but I suspect only by straight men;
  • Clare, the bartender from Afterlife, may be romanceable.

Other possibles are Misty the fae head-shop keeper, but I don't think so, and T-Bug, who would be really interesting but is I suspect no longer in the game.

Obviously, Night City has a very large number of sex workers, but my guess is that none of them is romanceable in any more meaningful sense than Meredith Stout is. I don't, as yet, know for sure that any of the romance options have any depth to them, although dear God one would hope so. For completeness, Meredith definitely swings both ways.

Johnny Silverhand is definitely not romanceable in the conventional sense since he only exists in your head; but I think we will (I haven't yet) at some point relive his memories of sex with Altiera Cunningham (who is also either dead or existing as a digital consciousness somewhere).

Tuesday, 10 November 2020

Virtual Cities

A review of Dimopoulus, Konstantinos: Virtual Cities; Unbound, London, 2020. ISBN 978-1-78352-848-6.

The Pelennor Fields around Minas Tirith, as rendered in Peter Jackson's film of The Return of the King, are at best rough grazing; the land outside Cintra, in Netflix' The Witcher series, is little more than moorland. This cannot be right.

Cities require large supplies of food, and consequently all pre-modern cities are built in areas of very high agricultural productivity. To support a city the size of Minas Tirith, the Pelennor must needs be not as productive as the Shire – because the Shire supports only its own peasantry – but substantially more productive. Of course, what this means in the modern period is that, as the cities expand, that very high quality agricultural land is built over and lost, but that is not what this essay is about.

But a city requires more than a significant supply of food. A successful city also requires a strategic reason to be where it is.

In the world I've been writing about for The Great Game, I have one city which completely breaks the rule of having an adequate agricultural hinterland, but there's a strategic reason for this. The city of Hans'hua controls the only possible water supply where the main trade route from the north coast of the continent to the south crosses a high desert plateau. Water is so valuable here that the city can, by taxing the supply of water to merchant caravans, afford to import substntially all its food.

At the time period of the game, this city has been, although small, very rich (and consequently, has excellent defences); its wealth is threatened, however, because advances in ship technology have opened up a new sea route, bypassing Hans'hua, and its decline has begun.

Another city, Tchahua, has grown from a fishing village to a modestly prosperous silk-weaving centre; but its fortunes, too, have suddenly changed. It controls one of the few deep water ports on the south coast suitable to the new ships, making it suddenly a vitally important node in the trading network; but because it has no history of being wealthy, it doesn't yet have defences commensurate with its new strategic importance, and is therefore a military target for every other power.

So cities – real cities – are not just consumers of resources (and thus, necessarily, producers of goods or services which they can trade for those resources); they're not just places of strategic importance. They're also dynamic entities, changing in response to the pressures that the wider economic and geopolitical forces impose upon them.

A virtual city doesn't, intrinsically, need to conform to these rules; but to be persuasive, to play a significant part in a persuasive narrative, it ought to do so, I think.

This is the pool of meditations into which Konstantinos Dimopoulos beautifully illustrated new book, Virtual Cities, has dropped.

The book is a substantial volume, as large and weighty as the telephone directory for any of the cities it describes. It is beautifully produced, colour printed throughout, elegantly and consistently designed, easy to navigate. 

Entry for Novigrad
Other than a relarively short introduction, it is essentially a catalogue of 45 cities selected from computer games. Each city is described in five distinct ways, three textual and two graphical: each city has a 'tourist guide' running to two to five pages, giving a feel for the city and written as though it were a real city that one might visit; a much shorter 'design insights' piece of less than one page, describing the city in the context of the game of which it forms a part, with insights into its realisation and technical innovation; a brief table of, essentially, bibliographical data (what game, developed and published by whom, in which year, and so on); a map of the city covering typically a double page spread, showing significant places and how they relate to one another; and pen-and-ink drawings of places within the city.

I'll say here that the style of illustration surprised and initially disappointed me. I had expected that the illustrations would be, at least nearly, screenshots taken from the particular games. They are not; instead, they are all drawn, in pen and ink, by a single artist, Maria Kallikaki. On reflection this is a good choice. It preserves the conceit from the 'tourist guide' that these are places one might really visit, and, at the same time, gives a cohesive visual style to the whole work.

I do not think that, for many people, this will be a book to read from cover to cover; certainly I have not done so. Rather, I have sought first the entries for some familiar – to me – virtual cities, like Novigrad, Whiterun and Dunwall, and then browsed to the entries for cities I have on my virtual bucket list but have not yet visited, and from there on to still others like Neketaka and Gabriel Knight's New Orleans, which I hadn't previously been aware of but now want to visit.

Of course this isn't – couldn't be – a comprehensive guide to all virtual cities, but rather a curated sample. I'm a little disappointed to find none of Rockstar Games' cities, as some of these, especially in recent games, are, I believe, very well executed. Most of the other major developers of games which present realistic urban worlds are represented.

BioWare are represented only by the Mass Effect series' Citadel, which I think is fair; none of BioWare's cities, that I've visited, has seemed to me well thought out or credible, they struggle even with villages – which, for a company with such resource and talent and which does so much else reasonably well, is surprising. Valve has City 17. Blizzard has Tarsonis. Infocom, Rockvil. Obsidian has New Vegas and Neketaka. Ubisoft are represented by Assassin's Creed: Syndicate's realisation of London, an entry which has made me more than ever eager to experience this for myself.
Map of Novigrad

CD Project Red are represented only by Novigrad. It's a reasonable choice; arguably their best realised city at the time the book was being written. Visima, in the original The Witcher game, was astonishingly well realised for its date; Beauclair is the most beautiful city they have released yet; Night City, due to open to visitors a month from now, promises to be by far their most ambitious and complex. Yet, excluding Night City, none of Visima, Beauclair or indeed Oxenfurt has any significant feature which Novigrad does not, and of them all, Novigrad is the largest and most complex.

Dimopoulos describes it as "one of the biggest, most thoroughly fleshed out, fantasy towns in gaming". I'd quibble a little with "fantasy," since Novigrad, although certainly fictitious, is so thoroughly grounded in Eastern Baltic history; but otherwise I wouldn't dissent from that judgement.

Of course, besides these big development houses, many smaller developers are represented, too.

Of course, not all these games consider the economic relationships of their cities to their hinterlands, although the better ones do. Of course, in not all of these games are geopolitical events even modelled, in still fewer do they cause observable change within the cities. And yet there is learning to be had from all these cities. Even those which fail, teach; because we can learn how they fail, and avoid it.

Modelling an entire city and its economy, making it traversible and navigable, and filling it with interesting, believable characters and action, is a complex, interesting task. There are a lot of moving parts. It takes thought.

And good books, which provoke thought, which introduce me to new cities to study, help enormously. For any geek interested in what makes game worlds tick, this book is a must have.

Saturday, 4 July 2020

The Ranger's sword hilt

Aragorn of the Dunedain, as
portrayed by Viggo Mortensen
My blog posts are often somewhat geeky, but this one may just be the most bizarrely geeky ever.

Consider the Dungeons and Dragons character class, the Ranger. The class is (in my opinion) essentially based on Aragorn of the Dunedain from the Lord of the Rings. The ranger is an often solitary wanderer of wilderness areas, away from inhabited areas for weeks at a time. Therefore, everything which the Ranger carries must be strictly necessary; they will have to make compromises to keep their entire pack light enough to manage. The ranger is skilled at observation and tracking, but also at concealment and at moving quietly. Consequently, when faced with potential opponents they cannot beat, the ranger will probably remain in concealment and avoid conflict. The potential opponents in the wilderness are likely, in any case, also to be travelling light; the chances of meeting a heavily armoured opponent are slim.

The ranger must carry a bow, since a lot of their subsistence will come from hunting. They must be very skilled with it. When faced with an armed human (or anthropoform) enemy, the bow is likely to be the first and primary weapon, since if you can do  injury to your enemy before they are close enough to do injury to you, your chances in combat are that much better. However, when the distance closes sufficiently that melee weapons can be used, the bow ceases to be very useful, either for attack or defence. So a sword as a secondary weapon makes sense (an axe might make more sense, since it can do dual duty in gathering firewood, but the preponderance of swords over axes in medieval weaponry implies that, in a fight between a sword and an axe, the sword must generally have won; and it's clearly a more nimble weapon, so this is understandable). A quarterstaff - a fairly stout pole of hardwood a little longer than a man is tall - might make sense for reasons I'm going to come to later, but like any pole arm it's an awkward thing to carry (although it could do double duty as a walking stick). In any case, I'm going to assume my ranger carries a sword.

A shield is a large, awkward, clumsy thing, as well as probably quite heavy. It cannot readily do double duty as anything else. I'm going to assume my ranger does not carry a shield. A buckler is possible but in the moment of throwing aside the bow and equipping melee weapons, it's one more thing you would have to be carrying and would have to equip; so I'm going to guess that my ranger doesn't carry a buckler, either. That means that, in melee combat, the ranger has both hands free to handle weapons.

Two styles of fighting are possible. One is sword and dagger, in the renaissance Italian style, where the sword is something probably approaching a rapier. But the rapier is not a versatile sword: it is primarily a thrusting weapon. It could not be used for cutting firewood, or opening a path through a thorn thicket. The other is a cut and thrust sword.

Our ranger is necessarily lightly armoured, since lugging heavy armour through the wilderness for at best very occasional use doesn't make sense, and it's noisy and takes a lot of maintenance, and you almost certainly wouldn't be wearing it on the very rare occasions when you needed it. If you're not armoured, then you don't want your enemy to get close enough to make effective use of their weapons, so you want as much reach as you can achieve (sorry, Arya Stark, that Needle won't help you much - and this is also where the quarter staff might make sense). So a longsword, or at least a 'bastard', hand and a half style sword, is the most appropriate sword. It has greater reach and, wielded with two hands, can land a more powerful blow than a single handed sword. In keeping with this argument, Aragorn's sword, Anduril, is a longsword. However, for the ranger in the wilderness, the slightly shorter bastard sword may be a better compromise, given that it is a (hopefully) infrequently used secondary weapon.

OK, so that solves the problem, nothing more to think about.

No?

Well, no, I don't think so. Because our ranger's primary weapon is the bow, and, when an enemy closes to melee range, the change from bow to melee weapon has to be quite swift. Medieval swords from Christian Europe generally had straight crossguards, which offer little or no protection for the hand against a thrust. I suspect part of the reason was that the sword with the perfectly straight crossguard at right angles to the blade made an extemporary Christian symbol - could be used as a portable temporary altar for a quick pre-combat prayer - was part of the reason for this very simple design, but another reason is that the sword was expected to be used with gauntlets.

The quillons - arms - of the guard are there to prevent your opponent's blade sliding up yours and either cutting into your hand, or, if deflected from the hand, entering another part of your body. Therefore it makes sense in a non-Christian culture to have quillons at least somewhat angled or curved towards the opponent, and, unsurprisingly, the quillons of many Islamic swords of the period are made precisely like this - but that's an aside.

The main point I want to make here is that an archer cannot wear gauntlets - certainly not on the hand used to draw the string, typically the user's dominant hand, which will typically be the hand closest to the enemy on the haft of the sword. So the classic medieval two handed sword with its simple cross guard leaves our ranger's dominant hand unprotected in a vulnerable position. This is precisely why small swords - gentlemens' dress swords, used on social occasions when armour wouldn't normally be worn - have much more elaborate hilts from the late medieval period; and why, by the time firearms had become the primary weapon of most soldiers, all swords had more elaborate hilts. The protection had migrated from the hand to the weapon.

Reproduction Swiss-style
hand-and-a-half sabre with simple
basket hilt.
So the guard needs to be extended at least to some degree. A basket hilted two handed sword is possible - examples (mainly from the sixteenth century) exist in both Switzerland and Germany, both with a basket protecting only the primary hand, and with a basket extending the full length of the hilt; and many of these, also, have finger guards. A basket hilt, of course, offers only limited protection against thrusts towards the hands; examples with shell guards also exist from Holland and Scotland, again around the sixteenth century, with the Dutch example having both a shell and a basket. Another interesting hilt design which might be considered is the 'Sinclair hilt', a (probably) Scottish design comprising a simple basket with a finger bar in the plane of the quillons and blade, with a plate metal loop at right angles to the quillons protecting the back of the hand.

Reproduction Sinclair hilt
More protection on the hilt necessarily makes a sword heavier, all other things being equal. Obviously, it adds the extra weight to the hilt, bringing the point of balance of the sword back towards the hand and reducing its angular inertia in cutting; it tends to orient the blade more towards thrusting than towards cutting. And a symmetrical basket hilt is said to be awkward to wear, because part of it necessarily projects in towards the torso when worn on a belt. However, if the basket is to cover both hands it must be to an extent symmetrical, at least sufficiently to be awkward in this way. So I think what we're looking at something between a Swiss hand-and-a-half sabre hilt, and bastard sword with a Sinclair hilt protecting only the primary hand, but the haft and pommel extending beyond the basket to allow grip by the other hand. Of the two, the Swiss sabre style would be lighter; the Sinclair style would offer more protection. My instinct is that the ranger would prefer the Swiss style, both for lighter weight and for better cutting.

It's worth noting here that once a basket hilt has evolved, one edge is always the primary edge of the blade, and most swords then quite quickly evolve towards single edged and subsequently curved; but straight double edged swords with basket hilts were in use in Scotland for at least three hundred years, and aesthetically (knowing very little about practical sword fighting) I prefer the look of a straight symmetrical blade.

Having said all this: in a fantasy environment we are not limited by what has been used historically. However, one thing we know about historical designs which were in use for a significant period is that they work and are practical.

So my ranger will carry a straight, double edged hand-and-a-half bastard sword, with an asymmetric half-basket hilt derived from the Swiss sabre illustrated above.
 

Postscript

 
Schiavona by Vladimir Cervenka

Since writing this I have been won over by this extraordinarily beautiful and graceful (and protective!) Schiavona hilt by Vladimir Cervenka.

A hand-and-a-half sword with an (obviously, for me, left handed) variant of this hilt is now an object of desire.

Tuesday, 23 June 2020

Pathmaking

NOTE: this essay is called 'pathmaking', not 'pathfinding', because 'pathfinding' has a very specific meaning/usage in game design which is only part of what I want to talk about here.
Visualisation of the port at Tchahua

Stages in creating routes between locations

The 'procedural' phase

see also Baking-the-world.

Towards the end of the procedural phase of the build process, every agent within the game world must move through the complete range of their needs-driven repertoire. Merchants must traverse their trading routes; soldiers must patrol routes within their employers domain; primary producers and craftspeople must visit the craftspeople who supply them; every character must visit their local inn, and must move daily between their dwelling and their workplace if different; and so on. They must do this over a considerable period - say 365 simulated days.

At the start of the procedural phase, routes - roads, tracks and paths - designed by the game designers already exist.

The algorithmic part of choosing a route is the same during this procedural phase as in actual game play except that during the procedural phase the route-map is being dynamically updated, creating a new path or augmenting an existing path wherever any agent goes.

Thus the 'weight' of any section of route is a function of the total number of times that route segment has been traversed by an agent during this procedural phase. At the end of the procedural phase, routes travelled more than R times are rendered as roads, T times as tracks, and P times as footpaths, where R, T and P are all chosen by the game designer but generally R > T > P.

Algorithmic rules

  1. No route may pass through any part of a reserved holding, except the holding which is its origin, if any, and the holding which is its destination (and in any case we won't render paths or roads within holdings, although traversal information may be used to determine whether a holding, or part of it, is paved/cobbled;
  2. No route may pass through any building, with the exception of a city gate;
  3. We don't have bicycles: going uphill costs work, and you don't get that cost back on the down hill. Indeed, downhills are at least as expensive to traverse as flat ground;
  4. Any existing route segment costs only a third as much to traverse as open ground having the same gradient;
  5. A more used route costs less to traverse than a less used route.

River crossings

Crossing rivers is expensive - say five times as expensive as level open ground (but this will probably need tuning). Where a river is shallow enough, (i.e. where the amount of water passing is below some threshold) then a path crossing will be rendered as stepping stones and a track crossing as a ford. Where it's deeper than that, a path crossing either isn't rendered at all or is rendered as a light footbridge. A track or road crossing is rendered as a bridge. However, the maximum length of a bridge varies with the amount of traffic on the route segment, and if the crossing exceeds that length then a ferry is used. Road bridges will be more substantial than track bridges, for example in a biome with both timber and stone available road bridges might be rendered as stone bridges while track bridges were rendered as timber. If the watercourse is marked as `navigable`, the bridge must have a lifting section. It is assumed here that bridges are genetic buildings like most other in-game buildings, and so don't need to be individually designed.

Representation

At some stage in the future I'll have actual game models to work with and $DEITY knows what the representation of those will be like, but to get this started I need two inputs: a heightmap, from which gradients can be derived, and a route map. The heightmap can conventionally be a monochrome raster image, and that's easy. The route map needs to be a vector representation, and SVG will be as convenient as any. So from the point of view of routing during the procedural phase, a route map shall be an SVG with the following classes:
  • `exclusion` used on polygons representing e.g. buildings, or impassable terrain which may not be traversed at all;
  • `openwater` used on polygons representing oceans and lakes, which may be traversed only by boat (or possibly swimming, for limited distances);
  • `watercourse` used on paths representing rivers or streams, with some additional attribute giving rate of flow;
  • `navigable` may be an additional class on a path also marked `watercourse` indicating that it is navigable by cargo vessels;
  • `route` used on paths representing a path, track or road whose final representation will be dynamically assigned at the end of the procedural phase, with some additional attribute giving total traversals to date;
  • `path` used on paths representing a path designed by the designers, which will certainly be rendered as a path no matter how frequently it is traversed;
  • `track` used on paths representing a track designed by the designers, which will certainly be rendered as a track no matter how frequently it is traversed;
  • `road` used on paths representing a road designed by the designers, which will certainly be rendered as a road no matter how (in)frequently it is traversed.
At the end of the process the routing engine should be able to write out an updated SVG. New routes should be splined curves, so that they have natural bends not sharp angles.

The 'Walkmap'

Conventional game pathfinding practice is to divide the traversable area into a mesh of 'convex polygons', where a 'convex polygon' in this sense is, essentially, a polygon having no bays. Routes traverse from a starting point to the centre of a polygon ajacent to the polygon in which the starting point is located. I have reservations as to whether this will do what I need since I'm not convinced it will produce naturalistic paths; however, it's worth at least experimenting with.

There are existing utilities (such as hmm) which convert heightmaps into suitable geometry files; however all I've found so far convert to binary STL. This isn't a format I find very useful; I'd prefer an XML dialect, and SVG is good enough for me.

hmm converts the heightmap into a tesselation of triangles, which are necessarily convex in the sense given above. Utilities (such as binary-stl-toASCII) exist to convert binary STL to an ASCII encoded equivalent, which may be easier to parse.

So the pipeline seems to be
  1. heightmap to binary STL
  2. (optional) binary STL to ASCII STL
  3. STL to SVG (where 'SVG' here is shorthand for a convenient vector format)
  4. Exclude holdings, buildings, open water, and other exclusions
  5. Where we have excluded exclusions, ensure that any non-convex polygons we've created are divided into new convex polygons.
I shall have to write custom code for 4 and 5 above, and, looking at what's available, probably 3 as well.

I'm working on a separate library, walkmap, which will attempt to implement this pipeline.

Pathmaking and scale

Dealing with large heightmaps - doing anything at all with them - is extremely compute intensive. We cannot effectively do routing at metre scale - which is what we ultimately need in settlements - across the entire thousand kilometre square map in one pass. But also we don't need to because much of the continent is by design relatively unpeopled and relatively untracked. The basic concept of the Steppe is that there are two north/south routes, the one over the Midnight Pass into the Great Place and the one via Hans'hua down to the Cities of the Coast, and those can be part of the 'designed roads' map. So we can basically exclude most of the Steppe from routing altogether. We can also - for equally obvious reasons exclude the ocean. The ocean makes up roughly half of the 1000x1000 kilometre map, the steppe and plateau take up half of what's left, mountain massifs eat into the remainder and my feeling is that much of the eastern part of the continent is probably too arid to be settled. So we probably end up only having to dynamically route about 20% of the entire map.

However, this doesn't get round the main problem with scale, and pathmaking. If we pathmake at kilometre scale, then curves will be necessarily very long and sweeping - because each path segment will be at least a kilometre long. And, actually, that's fine for very long distance roads in unpopulated fairly flat territory. It's not so good for long distance roads in rugged terrain, but...

Phase one: hand-designed routes

While, given the bottlenecks of the few mountain passes and the one possible pass over the plateau, the caravan routes we want would almost certainly emerge organically out of dynamic routing. But, actually, I know more or less where they need to be and it's probably easiest to hand design them. It will certainly save an enormous amount of brute-force compute time.

I think I have to accept that if I want Alpe d'Huez-style switchbacks up the Sunset and Midnight passes, they're going to have to be hand designed. The same applies to where the Hans'hua caravan road ascends the plateau.

Phase two: route segments 'for free' out of settlement activity

If we start by pathmaking around settlements, we can make a first start by giving the template for a holding a segment of track parallel to and just in front of its frontage, and a segment of path along its left hand and rear edges. That, actually, is going to provide 90% of all routing within a settlement, and it's done for us within the Settling phase.

Phase three: metre scale routing around settlements

So if we then collect groups of contiguous 100x100 metre zones each of which has at least one settled holding, we can route at one metre scale over that and what it will essentially do is join up and augment the route segments generated by settlement. Areas of dense settlement do not make up a great deal of the map. Note that experience may show that the metre scale routing is superflous.

Phases four, five and six: increasing granularity

Taking the augmented route map comprised of

1. The hand-designed, mainly long distance or plot-important routes;
2. The route segments bordering holdings;
3. The metre scale routing

we can then collect contiguous groups of zones each having at least one holding, where in phase four each zone is a kilometre square and divided into 100x100 grid so that we route at ten metre scale; in phase five we use ten kilometre by ten kilometre zones and we route at 100 metre scale; in phase six, 100 km by 100 km zones and we route at kilometre scale. Each of these phases, of course, starts with a routemap augmented by the phase before.

This process should automatically link up all settlements on the south and west coasts, all those on the north coast, and all in the Great Place; and seeing that the posited pre-designed caravan roads already join the south coast to the north, the north to the Great Place and the Great Place to the south coast, we're done.

At least one of phases three, four, five and six is probably redundant; but without trying I'm not sure which.

Tidying up

After the full set of increasing-scale passes is complete, we should automatically cull any route segments generated in the settlement phase which have never actually been traversed.

Following that, there may be scope for some final manual tweaking, if desired; I think this is most likely to happen where roads routed at kilometre scale cross rugged terrain.

Saturday, 8 June 2019

The quest for Zireael

Ciri draws her sword Zireael for the first time
Over the past six weeks I've completed my second full run through of the The Witcher 3: Wild Hunt, and I want to record my thoughts about it.

I set out with three main goals: to follow the 'Triss' path rather than the 'Yennefer' path; to rescue the Bloody Baron's wife, and generally explore that story more fully; and to win as many allies as possible for the battle at Kaer Morhen.

Regarding Triss versus Yennefer: these are the only two major love interests for Geralt in Witcher 3. In many ways they're similar: both sorceresses, both ambitious, both powerful politically, both manipulative, both prepared to use intimacy - and sex, although I'd like to draw a distinction here between the two - transactionally to achieve their objectives. And they're friends. In the previous Witcher games, Yennefer has not been present as a character, but in the novels, she is clearly Geralt's primary (but not exclusive) sexual partner, and it was mainly for that reason that I followed her path on my first run through. By the end of it I was pretty confident that this was a mistake, and, having now played through the Triss path, I more than ever satisfied that she is the better of the two choices.

Yennefer is more powerful and more glamorous, but has much more ambiguous morality. She willingly uses necromancy, and is unashamed at destroying treasured and ancient religious sites to draw power for her magical workings. I can think of no occasions either in the novels or in the books where Yennefer behaves in a way that is unambiguously generous. Even her care for Geralt's stepdaughter Ciri is at least plausibly an attempt to gain influence over Ciri's very substantial power.  By contrast, Triss refuses to use necromancy, and doesn't destroy other people's artifacts in the use of her power (that I can remember); she behaves with genuine generosity at least some of the time, including towards people there's no reasonable reason to expect will ever be able to repay it.

But both in the novels and in the games, there's a third choice of someone who seems better (and a better fit for Geralt's character, at least as I interpret it) than either, and that's Shani. Shani is not a sorceress, and not powerful. Instead she's a doctor of medicine, highly altruistic, extremely brave, tolerant of and generous to everyone. But in the Witcher 3 she appears only as a bit part - a potential casual shag - in the Hearts of Stone extension. That seems to me a waste of a good character, frankly, who could have made the main plot much more interesting and thus thrown light on the characters of the other two.

Whatever: when your choice is Yennefer or Triss, Triss is the warmer, the more supportive, the more caring, possibly the more sensual; although arguably Yennefer is the more glamourous, more challenging, the more exciting, the more acerbic, possibly the more sexual. My choice is Triss. I think it's the better choice.

The Bloody Baron is probably the most developed and the most narratively interesting side-quest in The Witcher 3. In my previous play through I had left his wife living with the witches in the bog, clearly mad, but caring for the children and having, it seemed to me, some quality of life. I took the view that while it wasn't a good situation, it was better than the other available alternatives. This run through, I decided to try to see whether I could reconcile the Baron with his wife, and I sort-of succeeded. The Baron and his wife (and to my great surprise, also his daughter) were reconciled after the crones were defeated; however, it didn't end well. Because I had released the spirit of the forest, Anna was cursed, and died. The Baron later killed himself. There is apparently at least one more, and significantly better, ending to this story, but I haven't found it yet.

As I said above, I set out to recruit as many allies as possible for the fight at Kaer Morhen. The Nilfgardian cavalry didn't actually appear, but had been despatched; otherwise, I had Keira Metz, Hjalmar an Craite, Ermion the druid, Letho the Kingslayer, both Triss and Yennefer, Zoltan Chivay (of course), and Vernon Roche and Ves. What I hadn't thought through was that there were bound to be very considerable tensions in that group, notably between the Kingslayer and the Temerian resistance - that was an interesting touch, and shows how carefully thought through the whole game is!

A pleasing moment was that, after the battle, Keira (who in my previous run through had been burned at the stake in Novigrad as a heretic), went off with the witcher Lambert on a quest, and we later hear that they'd married. While I hadn't previously felt particularly responsible for Keira's death, this definitely seems a better ending (for both characters).

However, related to that was one of my unexpected failures in this run: I didn't get into the narrative sequence in which Radovid is killed, and I didn't succeed in suppressing the religious intolerance in Novigrad; consequently, when Nilfgard was essentially defeated (which I had been intending), the Redanian army swept into Velen with their witch hunters and wreaked even worse desolation than I remember from before.

Whether there's any relatively 'good' geopolitical ending to the story I doubt: Nilfgard winning (as in my first run through) and Redania winning (as in this one) are both pretty appalling, but if there's a way - I don't know whether there is, and I don't want to be told because I shall make another attempt some day - of defeating both Redania and Nilgard, then I suspect that Velen, Temeria and probably Redania as well would become a seething mass of competing robber barons and warlords, with conditions for the peasantry as bad as ever.

It occurs to me that I have not explored what would happen if one encouraged Ciri to reconcile with her father, and thus possibly become empress; this might make for a better ending, geopolitically, for the world as a whole, perhaps; but it doesn't seem to me that it would be a better ending for Ciri.

I have to say here that from the point of the Battle of Kaer Morhen on, the whole story was radically different from what I remember from my previous playthrough - and I saw the beginnings of (but didn't complete) still further loops in the plot which it would be really interesting to explore some day. There is quite extraordinary richness in this storytelling.

I don't know whether there's any narrative link between the choice between Triss and Yennefer (of course you don't have to choose; you could play as a chaste witcher and bed neither) and the choice between Redania and Nilfgard. And, as I say, in this run through I didn't in any sense side with Redania - I didn't avoid the quests which would lead into the area of the story where that choice would be made, but that wasn't because I was consciously avoiding it.

On Skellige, I sided with Cerys an Craite, as I had before. To my mind, she is just a much better candidate for the throne than her brother. Consequently, I still haven't seen how, if at all, choosing Hjalmar would alter the story.

At each point where I had an opportunity to influence Ciri's choices, I chose to support her in making her own choice. That, I think, is similar to what I did before; it feels natural to me, and it also feels to me to be what Geralt would naturally do. But in the ending, Ciri went into the locked tower to bring an end to the white frost, something I don't remember from my previous run through, and in that scene I saw her recall all the times in the story when I'd taken her side and backed her up. That seemed to me extraordinarily poignant and positive, and very sensitively done. Bravo! Afterwards, when I told her father that she was dead, I genuinely believed it was so, genuinely mourned it, and genuinely wondered what misstep I'd taken; so the very end, where I was reunited with her and gave her her witcher's sword (something which definitely didn't happen on the last run) was a wonderful surprise.

To criticise - for no work of art is perfect - as I've written before many times before, the poverty of repertoire of the characters is, to me, very disappointing, and it does not seem impossible given the current state of the art that they could be given far greater depth of narrative. Whether that would take you into an uncanny valley I don't know, but I would like to see it tried.

The other major criticism I have is that - given that I play for story, not 'to win' - the big set piece fights really don't work for me. They are, for me, just boring. I'd much rather see the climax of the story through interaction with characters than just by great slash fests.

However, these are details; and they're details from the point of view of my personal taste.

So, once again: The Witcher games collectively, but especially The Witcher 3, are quite extraordinary works of cultural achievement, story tale on an epic scale which I don't believe is surpassed anywhere in any medium. If you have not experienced it, you have missed yourself.

Wednesday, 8 May 2019

Baking the world

Devogilla's Bridge in Dumfries, early foourteenth century
In previous posts, I've described algorithms for dynamically populating and dynamically settling a game world. But at kilometre scale (and I think we need a higher resolution than that - something closer to hectare scale), settling the British Isles using my existing algorithms takes about 24 hours of continuous compute on an eight core, 3GHz machine. You cannot do that every time you launch a new game.

So the game development has to run in four phases: the first three phases happen during development, to create a satisfactory, already populated and settled, initial world for the game to start from. This is particularly necessary if hand-crafted buildings and environments are going to be added to the world; the designers of those buildings and environments have to be able to see the context into which their models must fit.

Phase one: proving - the procedural world

I'm going to call the initial phase of the game run - the phase which takes place before the quest team write their quests and the art department adds their hand-crafted models - 'proving', as when dough has been been made and set aside to rise.

Then, when the landscape has developed - the areas of forest, scrub, open meadow, moorland, savanah and desert are determined, the rivers plotted, the settlers moved in, their trades determined and their settlements allocated, the roadways which link settlements routed, river crossings and ports defined - the proving process ends, and the world is turned over to the plot-writers, quest builders and designers, for a process we can see as analogous to kneading.

But, before going there, to summarise the proving stage. The inputs are:
  1. A raster height map (although this could be randomly generated using any one of many fractal algorithms) - this probably uses ideas from tessellated multi-layer height map;
  2. Optionally, a raster rainfall map at 1km resolution (although my personal preference is that this should be generated procedurally from the height map).
The outputs are
  1. A vector drainage map (rivers);
  2. A raster biome map at roughly 1 km resolution (it might be anything between hectare resolution and 1Km resolution,  but obviously higher resolution takes more storage);
  3. A database of settlers and their settlements, such that the settlements have x,y co-ordinates;
  4. A vector road map.
In this sense, the 'biome map' is just the end state of a Microworld run. The 'biomes' include things like 'forest', 'scrub', 'heath', 'pasture', but they may also include human settlement, and even settlement by different cultural groups.

This gives us all we need to vegetate and furnish the world. When rendering each square metre we have
  1. The x,y coordinates, obviously;
  2. The altitude, taken from the height map;
  3. The biome, taken from the biome map;
  4. The biomes of adjacent cells in the biome map;
  5. The proximity of the nearest watercourse;
  6. The proximity of the nearest road or pathway;
  7. Whether we are inside, or outside, a settlement (where for these purposes, 'settlement' includes enclosed field), and if inside, what type of settlement it is.
Given these parameters, and using the x, y coordinates as seed of a deterministic pseudo-random number generator, we can generate appropriate vegetation and buildings to render a believable world. The reason for pulling adjacent biomes into the renderer is that sharp transitions from one biome to another - especially ones which align to a rectangular grid - rarely exist in nature, and that consequently most transitions from one biome to another should be gradual.

Note that proving, although extremely compute intensive, is not necessarily a one-time job. If the designers aren't satisfied with the first world to emerge from this process, they can run it again, and again, to generate a world with which they are satisfied. It's also possible to hand-edit the output of proving, if needed.

But now, designers and story-writers can see the world in which their creations will be set.

Phase two: kneading - making the world fit our needs

Enough of proving, let's get on to kneading.

Hand-designed buildings and environments are likely to be needed, or at least useful, for plot; also, particularly, very high status buildings are probably better hand designed. I'm inclined to think that less is more here, for two reasons:

You cannot hand design a very large world, it's just impossible. How CD Project Red managed with Witcher 3 I don't know, since I understand that is largely hand designed; but that was a very large team, and even so it isn't a world on the scale I'm envisaging.

Procedurally generated models take a wee bit of compute power to reify, but not a huge amount, and they're trivial to store - you need one single birch leaf model and one single birch-bark texture generator to make every birch tree in the game, and probably a single parameterised tree function can draw every tree of every species (and quite a lot of shrubs and ground-cover plants, too). But once reified, they take no longer to render than a manually crafted model.

By contrast, a manually crafted model will take a very great deal more space to store, such that being able to render a large world from hand crafted models, without excessive model re-use, isn't going to be possible.

So it's better in my opinion to put effort into good procedural generation functions, not just for foliage but also for buildings. My reason for using a picture of a medieval bridge at the head of the essay is to illustrate exactly this point: even in the medieval period, bridges comprise a series of repeating modules. Take one arch module and one ramp module from Devorgilla's bridge as models, add texture skins for several different stone types, stretch the modules a little in whatever dimension is needed, and repeat the arch module as many times as needed, and you can create a range of bridges to span many different rivers - which will all be visibly similar, but that's fine, that's the nature of a traditional culture - but each slightly different.

Take half a dozen sets of models - timber bridges for forested biomes, brick bridges for biomes without stone or timber - and you can build procedural bridges across a whole continent without ever exactly repeating yourself.

However, in some places the designers and story writers will want, for plot reasons and to create iconic environments, to add models. I'm inclined not to over do this, both for reasons of development effort and for reasons of storage cost, but they will. Very high status buildings may need to be unique and distinctive, for example. These need to be designed and their locations and spatial dimensions added to the database, so that the models can be rendered in the right positions (and, critically, procedurally generated models can be omitted in those positions!)

Story and quest writers will also want characters for their plots. While there's no reason why writers cannot add entirely new characters to the database, there's no reason why they cannot incorporate characters generated in the settlement phase into the story; for this reason, characters need to be able to be tagged in the database as plot characters, and with what quests/elements of the plot they're associated.

This allows a mechanism to prevent a plot character from being killed by another non-player character, or dying of disease or starvation, before the plot elements in which they feature have been completed.

Phase three: baking - making it delicious

Once the world has been populated, settled, vegetated, the story has been written, the models built, the quests designed, there is probably a process of optimisation - stripping out things which aren't needed at play time, streamlining things that are - before you have a game ready to ship; but really I haven't yet given that much thought.

Phase four: eating!

At the end, though, you have a game, and a player plays it. How much of the dynamic, organic life that brought the game through proving continues on into the playing phase? If the gossip ideas are to work, if unscripted, non-plot-related events (as well as scripted, plot related events) are to happen while the player plays, if news of these events is to percolate through the world and reach the player in organic, unscripted ways, if a lot of the emergent gameplay I'm imagining is to work, then quite a lot of the dynamic things must be happening.

Of course, part of this depends on the length of 'game world time' is expected to elapse in the course of one play through of the game. If it's less than a year, then you don't need children dynamically being born, and characters dynamically growing older; but if more, then you do. Similarly, you don't need a real simulation of trading to dynamically drive prices in markets, but for a fun trading sub-game to emerge, you probably do, and if you are using merchants as news spreading agents the additional compute cost is not high.

And I understand that many game writers will shudder at the thought that a war might (or might not) start in the middle of their plot, that a battle might, one time in a thousand, take place right where they've plotted some significant encounter. Most modern video games are essentially just very complicated state machines: if you make this sequence of choices, this outcome will happen, guaranteed. Or else they're puddles of random soup, where everything that happens is more or less driven by a random number generator. What I'm envisaging is something quite different: a world in which traders gonna trade, robbers gonna rob, lovers gonna love, scandal-mongers gonna make scandal, organically and dynamically whether the player is there or not, and news of these events will filter through to the player through the gossip network also organically and dynamically.

A world, in short, through which no two runs will ever be the same, in which interesting bits of story will happen with no-one directing or scripting them. And for that to work, some of the same dynamic processes that drove the proving phase have to continue into the eating phase.

Monday, 8 October 2018

Sex, the Iron Maiden, and NPC repertoire


Jutta and Geralt
I've written before, several times in fact, about the immersion-breaking poverty of repertoire of non-player characters (NPCs) in role playing games; but I've just tripped over a particularly egregious example in The Witcher 3: Wild Hunt, which I think of as the best software role playing game yet written.

On the Skellige Islands - on the Island of Faroe - just east of the village of Harviken, there's a hilltop fencing arena, and in it you'll find Jutta an Dimun, a sword-mistress who has vowed to her goddess, Freya, to lie with only a man who can beat her in single combat. Thus far, no man has. She won't fight you unless you've proved to her that you're a worthy opponent, and there are a number of ways you can do this; once you have, you can fight her. If you get to her early in your path through the game she's a very tough opponent, but her level does not scale adaptively to the player's, so if you encounter her late in your game you're likely to find her rather easy.

If you do beat her, she'll invite you to her home in the evening; if you go, it's not so much a matter of her being easy to seduce as her actively anticipating sex. She's rueful that she's been beaten by a (sterile) witcher, but she's most certainly willing.

You can choose not to have sex with her; you can advise her to go to the other islands where she may find non-sterile opponents who might beat her. But realistically, I think, few players are going to choose that option.

The alternative is to allow the evening to take its course, and if you do this there is a very sensuous and erotic sex cut-scene; the most sensuous, I think, with any NPC who is not a major character. It looks like stonking good sex (although weirdly, unlike in sex scenes with Triss, both parties keep their underwear on, which you'd think would be a trifle awkward - but that's nitpicking). After the sex scene, you wake up, still in your underwear, beside Jutta.

And if you try to talk to her, she has literally nothing to say. Not a single word.

In my experience, good sex isn't like that. In my experience, good sex results in some degree of warmth, of affection, of companionship between the participants. You'd expect at least an offer of breakfast, a warm farewell, perhaps a discussion of future plans, almost certainly a hint as to whether another encounter would be welcomed.

Even very bad sex is rarely like that. After bad sex, you may have strained politeness, you may have anger and bitterness. But nothing? Just nothing?

You can go away, do other things, and come back; and still she has nothing to say. Nothing at all. If it's a sulk, it's an extremely persistent sulk.

CD Projekt Red were rightly (in my opinion) criticised for making seduction effectively a mini-game within the original Witcher game; many female NPCs were seducible, and you were rewarded with a little card for each one you 'scored', leading to a degree of motivation to seduce them all. But only two such encounters led to any meaningful engagement with the character; the rest were 'one night stands' in the strictest possible sense, making your interaction with these characters in effect pretty exploitative. In subsequent games this aspect has been dialled back sharply; opportunities for seduction are much less common, and are mostly with women with whom Geralt has established relationships, or who are significant in the plot.

I don't think it's OK that sex is just an opportunity to 'score' with no consequences. There should be some plot consequence to whether or not you choose to have sex with Jutta; and whether you do or not - but especially if you do - there really should be some repertoire that expresses her attitude to you after this encounter.

It just is horribly wrenching - utterly immersion-breaking - that there is just nothing.

Creative Commons Licence
The fool on the hill by Simon Brooke is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License