Learning logic with Sherlock Holmes

Yesterday we turned on conditional logic in inklewriter. That's a big load of extra functionality, that lets you write stories that remember what the reader chose and did, and then use that to alter what happens later on in the story.

To demonstrate the functionality - and test it works! - we wrote a short example; a retelling of the opening of The Adventure of the Musgrave Ritual by Sir Arthur Conan Doyle. It's quite a short thing to play-through - have a look - but it uses a surprising amount of logic to keep the text smooth. This post gives a little detail about how it works.

The interactivity

The first decision in writing an interactive story is, how will the interactivity be framed? Is the reader role-playing a character? Is the reader taking an abstract position, co-authoring a story ("Make Ted angry", "Now someone else comes in")? Or is the reader talking directly to a character, over a telephone - or, as Dave Morris did in Frankenstein, something more like the voice in the character's head?

For the Musgrave Ritual, we wanted to stay as close to Conan Doyle as we could, so we kept the Watson narrative point-of-view. So the reader takes on a kind of first-person point of view role, guiding Watson - and more often than not, since Holmes stories are all about Holmes - telling Watson what to say next to his friend.

Keeping the text making sense

These kind of options can vary simple details, like, does Watson get up to stoke the fire, or is it Holmes who does that? The Musgrave Ritual tracks little details like that, and then uses them later to vary the text appropriately. Here's that example:

And here's that flag being used to vary the text that is produced:

Tracking mood

Providing choices for how Watson will act lends itself to letting the reader shape that relationship a little bit, just as different actors do in the various adaptations of the stories that are made. Will Watson be a solid, jolly good chap, following Holmes every instruction, as he is classically? Or will Watson be argumentative and almost surly, as Guy Ritchie would have it?

The Musgrave Ritual lets you choose between the two, and keeps track of your choice using a really simple counter, which goes up by one every time you choose a moody option, and goes down when you apologise. (The counter is called "mischevious", to reflect that Watson doesn't really mean it when he gets angry.)

The counter is then tested in order to vary the options the player gets, such as at this point in the story, where only really moody readers will get to insult Holmes outright:

And we also use it to vary the text a little bit, so that surly Watsons will "argue" and "demand", where calmer Watsons will "rejoin" and "ask". Using these "inline conditionals" gives a writer tremendous power to easily colour text with different tones and voices without having to write lots of complex branches.

Loops and unlocking options

The last and most complex use of conditionals appears when Watson decides to examine the objects from Holmes' collection to do with the ritual. This section uses a loop, which unlocks more items the player can examine as they examine some, and eventually offers an "exit condition" that lets them continue the story.

Here's how it's done.

There's one other piece to the puzzle: in each of those options, two markers are used - one to increase the "number examined" counter, and the other to set the particular marker for the item the reader just looked at.

And notice that conditional bar on the text at the start of the loop - that's what stops the player seeing the same text over and over again every time they come back to the same place in the flow!

Other tips

Some other tips from writing a story with lots of branchiness:

Play the Musgrave Ritual!

Start writing now!

Disqus Recommendations

We were unable to load Disqus Recommendations. If you are a moderator please see our troubleshooting guide.

Hear all the latest news on inkle's projects.

Hear all the latest news on inkle's projects.

A Highland Song - development blog

Hear all the latest news on inkle's projects.

A Highland Song - development blog

Highland game updates

Hear all the latest news on inkle's projects.

Highland game updates

Disqus Comments

We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

G

Join the discussion…

Comment

Log in with
or sign up with Disqus or pick a name

Disqus is a discussion network

Read full terms and conditions

This comment platform is hosted by Disqus, Inc. I authorize Disqus and its affiliates to:

Acknowledge I am 18 or older

Favoriting means this is a discussion worth sharing. It gets shared to your followers' Disqus feeds, and gives the creator kudos!

Find More Discussions

Share

I really love the conditionals, and I wonder if this is possible:

If I have something set to random -- let's say, "You're wearing a {~red|blue|green} hat." -- and the system chooses blue this time, can that choice be automatically and consistently replicated throughout the story? So now, every time the hat gets a mention ( [value:hat_colour] or something), it always comes up as being blue.

On the next read through it might choose red, in which case all other instances of the hat's colour are also set to red.

Can this be done? Thanks in advance!

see more

Show more replies

G

Thank goodness for Erik T's comment or I would be Hair -2 and as I'm already Hair <= -6 that would be {~ugly|shiny|painful}.

I’m appreciating the effort you’ve put into the Inkle concept very, very much - thank you guys. I am enjoying your ‘Frankenstein’ on Android, and am using one of my ideas begun in Twine to get to know Inkle. I&#039ve completed a couple of Twines and started trying out Ren’Py - so these are Inkle loving thoughts and observations from both a beginners and a new to Inkle perspective

Everything Erik said about lozenges is spot on; I just could not work out where I was going wrong with the conditionals because they seemed to be in the ‘wrong’ place. Then once an option is taken, its conditional lozenge disappears.

It would be really useful to have the conditional lozenge that controlled an option be on top before taking that option and ‘stay on the top’ of it’s result as a passed waypoint after taking that option.

Fragments sliding-in from way out in left field take my eye off my writing unnecessarily. Sections might slide in less obtrusively, and more in keeping with your layout were they to sneak quietly in from the bottom up in the reverse of Rewind.

I can’t see what I’m doing without an indication of my location within my story concept. I know you&#039ve just introduced a map, thank you, but I can’t glance at it without disrupting my flow. Might there be room to allow a linear, vertical map running down the left hand side - a mirror of the Contents area - and allow Contents and/or Map to be visible at the same time as the Writing area if the author wanted?

Markers are everything, but the Tutorial didn’t stress this enough for me.

After many tutorial back-and-forths I began to think that as well as creating Markers for myself, Markers could be somehow automatically created by the action of the reader taking one choice or another. Create versus Set confusion on my part.

The descent into a little code when I came to conditionals threw me into thinking that ‘Number’ and ‘First Route’ were embedded code names set by Inkle rather than examples of the author’s chosen Marker names.

Having a tutorial embedded in Inkle doesn’t completely work as the only tutorial document. Having to Rewind combined with the sliding-in effect is a quick reference pain.

Basic Inkle concepts in a block of text with annotated images might help enormously, or a video tutorial when time and resources allow. I realise my observations are relevant to any writing system not, just Inkle, but as you guys seem to be ‘on it’ for us beginners...

The mention of ‘auto complete’ makes me think there could be a way to access all programming commands in a simple manner; either this or a crib sheet would be bliss for all new authors.

Thank you. Keep it up. Pleasure + 1 = Inkle.

see more

N

Is it possible to print out the current value of a counter?

see more

J

Yes. Take a look at the "quick questions" section of the tutorial for a working example, but basically there are two "inline functions" for doing this, that look like [number:numberToPrint] or [value:numberToPrint]. The first prints a number ("7"), the second prints the value in words ("seven").

(Note the square brackets here, not curly brackets, as this isn't a conditional.)

see more

Here is a tip for using markers to track direction of movement. I started by having markers for North, South, East, West, or Left, Right, Forward, Back, but these quickly become unmanageable because you have to update all for each direction change. Instead, I substituted ONE marked called "direction" and that allows me to set the value to any number from "0" for due North, to "359" degrees, so with a single marker, you can track 360 degrees of the compass.

see more

A

Can I allow the reader to choose their own name for the character they are playing?

see more

N

Quick question: Is it possible to nest OR statements inside a logical test when choosing to show an option or paragraph?

I'm trying to test the absolute value of a marker to determine what paths are available for the reader. Once a marker reaches +/- 3, certain paths will become open or closed.

Any ideas?

see more

Is it possible to create a string variable, like letting a reader input their own name and calling it back later? And is it possible to create new pages so that the story doesn't play as one insanely long scrolling box?

see more

Apologies, basically no to both. You can hyperlink a story to another story to achieve sorta-that-effect, but you can't carry variables over. Essentially it's beyond inklewriter's scope.

see more

How about just putting some empty space between paragraphs? Or other basic formatting besides bold and italic? To make bigger Chapter headers for example

see more

You like sherlock? We love sherlock!! https://igg.me/at/brothaholmes

see more

I was wondering if the counters can be tested past sections. I want a total of markers from section 1 to section 10.

I have a moldable character and I'd like to (by the end of the tale) have their projected future change based on the markers/ +1 counters. I also don't know where the test function is. The if widget simply lists to flag for the marker or flag without the marker.

see more

Is there any way to use strings? I'm writing a story with two sides, and the player chooses which side he/she's on. I want to be able to print which side the player is on.

see more

Wait, I realized you can change the text based off of a variable.

see more

L

Is there a way to work on an Inkle story collaboratively, by, for example, several students in a group assignment? I love Inkle so far!

see more

Apologies, no; in fact, if you try sharing logins each writer will overwrite the other's work - so don't! Inklewriter just can't cope with simultaneous changes being made by several people.

see more

I'm very confused about conditionals - in particular the last example where there's a loop of more than one thing that can be done before moving on. You say there are markers that can be added to the options, but I'm only seeing markers available for the paragraphs. Am I missing something? Can you explain this a bit clearer?

see more

So you can *set* a marker only a piece of text -- which makes sense, that means that bit of text has been seen by the player. But you can *test* a marker on either a paragraph or an option. So if you have a loop, you can add an "IF" condition to the last option which tests the player has seen some of the content from the other options in that loop... and then that option will only appear once the player has been around it once.

Is that clearer? ;)

see more

I am having a hard time understanding the counters, how they are established and such. It is mentioned that it is a "bit like coding"--is this to say there is a profound amount of possibilities?

Is there a link to more "logic" examples, ideas? Is there also a place for users to make suggestions to the program? I am thoroughly enjoying it thus far.

see more

J

How does one get the conditional options to appear, like the one to change reactions based on mood in the Holmes story? I can only see the way to show an option if a marker is passed.

see more

J

There's a "widget" for it: make sure the cursor is in the paragraph or option you want to add the conditional to, and then click the "if" button bottom-left. Good luck!

see more

A

I noticed when playing the Musgrave ritual there is a misplaced parentheses.

Holmes resumed his seat, picking his way across the bundled stacks of manuscripts that littered the floor}.

see more

J

Thanks! That's fixed.

see more

AW

Also I noticed in the tutorial that the parser doesnt like this this:

"So, you're a {boy:man | {girl:girl|mysterious figure} } who thinks beans are {likes beans:, at least, okay | nasty }. Good to meet you."

It comes out in the reader as:

"So, you’re a man } who thinks beans are, at least, okay. Good to meet you."

Like it's not understanding the nesting.

see more

I know it's been two years for you, but could you elaborate what intent your nesting logic is used for?

see more

I guess it's for making the text reflect what happened after you join the story back together again. So, say, you can have text like

"this was the {argued_with_bill:first time I'd seen Bill since our fight |{met_bill: second|first} I'd met Bill }."

That has three different ways it can go depending on if you've never met him, you met him, or you met and argued with him. And it's very quick to do; so easier than making a new paragraph for each version (though you could also do that, of course.)

see more

How is the code recognized through the text? Is it user created with simple logic keywords or is there a right/wrong way to do it? This is very useful, thanks :)

edit: is there a blog post dedicated to useful examples like this?

Also, is there a way to do this with IF statements using the ~shuffle?

e.g., {~big|small} then have like an IF statement of [if BIG then such and such]?

see more

J

Thanks, that's now working correctly.

see more

AW

(oops, I do indeed see a save indicator now - you folks are fast :) )

see more

AW

One comment on the inline conditionals - there are several autocomplete libraries that you might consider adding that would be able to look up the list of conditionals and "autocomplete" them much like you see on IOS or search engines.

I echo the comments about the placement of the lozenges - you want to have a consistent way for the user to know what label applies to what text - and having the conditional above the next text seems to be more consistent with your top down style of writing.

Also, I noticed that a story I was working on (The Enchanted Cave) seems to have disappeared (rolled back to a much earlier time) was there some server hiccup? I wish there was an explicit "save" button that one could press - even though I know it's supposed to auto save - I dont see any visual save indicator so I dont know if all the work I'm doing is saved or not...

see more

J

Auto-complete here is definitely worth considering!

Sounds like we maybe need to make that save indicator a bit easier to see and more "reassuring".

Server issues should now all be resolved! Thanks for your feedback!

see more

M

The "have a look" link in this post is broken.

see more

JH

Thanks very much, it's now fixed!

see more

ET

The UI looks great. Simple to use, easy to see what's been applied--good work! Maybe one day I'll find time to actually sit down and write something with it rather than simply look in through plate glass...

One thing bothers me quite a bit though: the placement of the conditional "lozenges". They are placed below the sections or options that they modify, but in terms of the logic of reading, I feel like I want them to be placed *before* the text they control. More importantly, they appear on the line between two sections or options, so it's not instantaneously clear which they apply to. As I read this post, I found myself working way too hard to figure out which options applied to which bits of text.

One final thing: it's not easy to use The Musgrave Ritual itself to understand what conditionals bring to the table, because the authorial view is not enabled, and because you have to rewind to the beginning of the story in order to explore different choices. If possible, you might want to link back to this explanatory post from the Musgrave page.

see more

JH

Thanks for the kind words! And really good point on the lozenge placement. We should have a think about that...

see more

Load more comments

live.rezync.com

live.rezync.com is blocked

This page has been blocked by an extension

ERR_BLOCKED_BY_CLIENT

Reload

This page has been blocked by an extension

pippio.com

pippio.com is blocked

This page has been blocked by an extension

ERR_BLOCKED_BY_CLIENT

Reload

This page has been blocked by an extension

Invisible link to Joe's Mastodon for verification Invisible link to Jon's Mastodon for verification