Show me the code: cpuid and popcount

 

So, modern CPUs have built-in functions for a lot of things, these days, which can offer you blisteringly fast access to some otherwise rather awkward and slow algorithms.

In my case, I wanted to access the CPU’s popcount function (count how many set bits there are in a value). The trick is that either the CPU supports it or it doesn’t, and different systems have different ways of testing if it does, and accessing it if it does. Of course if the CPU doesn’t support it, you still have to do it in software anyway.

So, I thought I’d write something extensible, and I thought I’d share.

Continue reading Show me the code: cpuid and popcount

Romance without routes. Breaking the CYOA/VN formula

Choice-based interactive-fiction comes in a whole bunch of narrative models. If you haven’t read the These Heterogenous Tasks article, Standard Patterns in Choice-Based Games, you should run right out and do that. It’s excellent, and I’ll be making some references to it. I’ll wait. Promise.

Done that? Good, let’s move along.

Continue reading Romance without routes. Breaking the CYOA/VN formula

How can your own characters surprise you?

You are responsible for their every thought, their every word, their every gesture. Not a one of them bears so much as a single punctuation mark that you didn’t put there.

But you hear writers say, “My characters surprised me.” It happens. It’s happened to me.


First, a little context.

I’m writing a multi-perspective branching novel, where the all of the main characters are simultaneously experiencing the narrative and making their own choices about it. You, the player, pick a character at the beginning, and ride along with them, making their choices, and following the narrative where it goes.

As seems to be usual for a writer, I selected my stable of characters, and invented as much information as I needed for them to fulfil their roles in my story. Gender, age, profession, prior knowledge of other characters, and so on. With a variable narrative you have key points where you know things need to be – or maybe points where you know they might get to. You fashion your characters to take your narrative to those milestones.

Fit-for-purpose characters, with the traits you designed, ready to line up on stage and perform whatever lines you hand to them.

But the tale grows, as they say, in the telling.

Each character’s narrative in this story is a complete thing. They speak and do, but they also think, consider and feel, all of which rolls out in a first-person narrative. Normally all that extra guff is reserved for the protagonist of a story, but I have a dozen protagonists right now. The narrative is complete, no matter who’s eyes you’re looking through.

That means you hold the characters apart, in your head. Apart from yourself and apart from each-other. You visualise each one as a living being and you think, what is going through his head right now? What is she feeling? And why?

And as the words scurry out into the keyboard from the fingertips, they surprise you.

This character has suffered at the hands of a sexist institution. That character is hiding his past. He prefers beers. She likes a certain kind of pastries. He is shy. She suffers from post-traumatic-stress disorder. He was (unexpectedly) married.

Temporarily, each of these characters gets to use your brain and your knowledge of the setting as you put yourself in their shoes. They suddenly know things about people or places or events that you did not know until they did. Having found it, it becomes a fact. And it snowballs. They make your world and themselves more solid, and the more solid it all is, the more interesting they become.

And things you planned ahead for? Well, maybe some of those have to be discarded, but what you get in exchange is just so much better.

Have you played D&D? Been the Game-Master, switching between a dozen NPCs, while you interact with your players from behind all those faces and personalities? Ever had your prepared material go out the window because of those interactions? It’s like that.

Solid characters in solid situations will surprise you. Thin characters will make themselves more solid (because underneath all your meticulous, or not-so-meticulous, planning that’s where your head is taking them).

But it’s your own head, isn’t it?

Well, yes and no. What did I see the other day? Oh, yes, this:

The king does the writing. You just whisper in his ear.

 

 

Kinetic Narrative vs Kinetic Novels: Exploring Kinetic Narrative

Kinetic novels mostly (though not entirely) derive from Japanese publisher VisualArt’s[sic], and its brand キネティックノベル (kineticnovel – smart money says it’s a trademark, so insert usual trademarks blahblah, and let’s move on). The thing that distinguishes kinetic novels as a subclass of visual novels is that they are not choice-based.

However, visual novels (whether kinetic novels or not) use a particular narrative presentation that is best described as “kinetic narrative”.


Kinetic narrative is an interesting beast. The user/reader clicks through the story a bit at a time, which reveals more. Choices that alter the story may or may not be a feature. The important part is the that the user interacts with the novel to reveal the next line, chunk or paragraph.

This brings some interesting features to the table. It allows for a kind of narrative that regular novels don’t, and might be actually a touch more reminiscent of the narrative style in comic-books and graphic novels.

Kinetic narrative allows interesting alterations in tense (permitting occasional graceful changes between past-tense and present-tense), since the user has become directly involved in the motion of the story, and the author can control what sized bites or chunks of text are revealed each time the user steps forward.

Since the user’s gaze can’t arbitrarily skip down the page or onto the next, kinetic narrative has more opportunity to generate surprises or suspense in less space, without having to more laboriously build up over time as you would in a format where the users gaze is uncontrolled.

Oddly, this seems to allow for a more natural form of writing, where you can avoid traditional gimmicks like a comic-book’s habit of placing punch-lines at the end of a page, and surprises or reveals on the next non-facing page. Consider also how traditional novel writers build suspense and perform reveals in relation to the way chapters in a book are laid out.

Kinetic narrative allows us to divest ourselves of a lot of traditional cruft that are associated with the inability to control the reader’s gaze. The reader’s gaze isn’t a problem for kinetic narrative. It sees exactly as much as we wish it to see, and no more. That allows us to create more natural flow in narrative, generate short-term suspense, surprises, create more immediacy, and handle reveals without having to resort to more cumbersome narrative forms.

As a bonus, kinetic narrative doesn’t let the reader’s eye get lost on the page (you know that bit where you accidentally wind up losing your place, on the page often due to external distractions, and have to pick it up again)?

I’m very much starting to warm to kinetic narrative over traditional narrative as a style. It’s not that I don’t appreciate both forms, but that I’m starting to see advantages to the kinetic form that were not initially apparent.

 

Branching story planning

I have a chart of the way scenes branch in the SNAFU story. You might have looked at that and thought “Well, that looks a tad complex” – or maybe you didn’t. Maybe you thought it looked quite straightforward compared to branching fiction that you’re familiar with.

For a refresher, this is a chunk of the diagram:

snafu1

It has grown a little since then. The thing is, that traditionally, the scene is the “atomic” node of choice-based interactive-fiction, and that is not the case here.

Continue reading Branching story planning

Regression and ignorance

One of the more involved aspects of the Argus story engine is how characters learn and express information about each-other. Some of that knowledge is just used for conditional narrative, but the most important part (currently) is how characters address each-other.

Names, titles, nationality, differing levels of formality, age, gender, and more, all get churned through sets of constructs provided by the story, which ultimately result in some form of address. That’s what I call the reference model. It’s updated as characters learn new information about each-other, and gaps in the knowledge-structure are filled in with assumptions, where no direct knowledge exists.

And annoyingly, way down in scene 360, one of the characters seemed suddenly unable to create a valid form of address for the character she was speaking to.

Continue reading Regression and ignorance

That’s what you get

What do you get when you rework, redesign, extend and simplify your conditional expression evaluators? You get bugs, that’s what you get.

Thankfully, nothing was terribly difficult to figure out, once I’d actually discovered that the bug was there at all. The problem was that I didn’t notice for about a day.

Continue reading That’s what you get

Rewriting text output

Rendering text in a graphical environment is … let’s call it ‘involved’. Assuming you want to output a single line of text in a single typeface and colour, that’s pretty easy. The interface libraries will even probably be willing to word-wrap it for you.

If you want to do other things, like mix plain text with italics or bold or text in other colours, well suddenly you’ve got dozens of hoops to jump through.

Well, I did want that, so I had to work for it.

Continue reading Rewriting text output

Story length, surprising characters, and planning

Talking about story-length can be like asking “How long is a piece of string?”

Work flows back and forth between optimising the Argus engine and working on the showcase story, SNAFU. SNAFU’s up to 135,000+ words now, and that’s more than 13,000 lines of script.

I have a testing mode that allows the story to run without the requirement for a human user. The actors perform their scenes, and make their choices, until the system runs out of story for everyone. Everything that happens gets written out to a log, where I can check each actor’s personal narratives.

That takes about a second and a half. It takes longer to load the story from the disk than it takes to process it all to completion.

I guess the optimising efforts have not been wasted, though I have somewhat mixed feelings about all the effort in content-creation resulting in such a short unattended runtime.

Continue reading Story length, surprising characters, and planning