Dark Forest Crow Notes - Interactive fiction, text-interactions based and roleplaying games

Saturday, July 23, 2016

Modern text-based adventure games development #3: Solutions

    Time for another post of thoughts. Previously we discussed problems that are common for modern (and not only) text-based adventure games development. Again, this is not a tutorial. I'll write some tutorials for those who are planning to develop their own games later (yes, there are tons of such tutorials already on the internet so hopefully I will change my mind and will not do that).


Looking at fellow developers that suffer from poor development tools

So, text-based adventure games usually have such problems:

1.) Poor natural language processing capabilities.
2.) Primitive gameplay and game mechanics in general.
3.) Primitive characters or even no 'real' characters at all.

    Why is it so sad? I think the roots of these problems are in interactive fiction community ideology that is obsolete. Ken Poirier from a comment section on our facebook page also added that one of the problems with text parsers is that games are often designed to be compatible with the old z-machine system. Well, this is one of the reasons. You can read about z-machine here.


    All things listed above can stop you on your way to creation of your unique text-based game. So, what can you do about that?


    Again, if you want to create simple ('traditional') interactive fiction game as fast as possible - take a look at Twine or Inform and come back later. You can also skip everything below for now.

    I see only one way of text-based games development that can help you achieve good results without forcing you to study things you will never use again:


    You can develop your text-based game like it's a real game. Yes, strangely, but text-based games are computer games too, so you can just...program text-based games using any programming language you know. This is the only way to create something really unique and the only way that gives you complete freedom in your creativity, as well as useful experience, knowledge and portfolio.


    You may think 'but why do I need to create everything from scratch and create yet another set of crutches?', and I am ready for that.


    Below are some ideas about text-based games in general. Text-based games are simple (if we talk about development process) - you don't need graphics with outstanding landscapes or cute pixel 

art characters, you don't need marvellous music, you don't need top-notch voice acting - just something that allows you to print text on the screen. And maybe a good compelling plot. Maybe.

    Let's pretend we want to create a text quest or any kind of interactive fiction. If you played some text adventure games you could see that usually the gameplay of such kind of games goes in this way: 


    Process input text-> Display output text -> Repeat

    Actually, that's all. 


    So, do we really need some special software tools like Twine, Adrift or Inform to create such a game? A lot of people are working right now developing these tools to help you to do what exactly? - request user input via text field, process (in a very simple way) received input and then just display a response.


    That's all. Literally. 


    If you need something advanced - these people and these tools will answer you 'sorry, mate, we can't do that, do it yourself'.  Maybe they can offer you natural language processing? - No, of course no. Easy-to-implement ways to create game world that is more complex than connected rooms? - No. Tools to create your NPC with replics, emotional state, memory? - You know the answer.

    You may think again (I see you like to think) 'But actually you can simplify any kind of games in this way. Crysis processes some inputs, analyzes it, displays some korean soldiers, then you hear pew-pew and that's all'. No. It's not that simple: you need graphics engine, 3d models, you need sound libraries, you need voice acting, you need animations, you need physics, you need math, you even need artificial intelligence...Not that easy to create everything solo.

    I am just saying that fellow reader can create text-based games from scratch using any programming language with it's basic functionality.


    Text-based game usually takes input strings and displays strings as answers based on some conditions. For example, your game can have such kind of conditions: current game zone, player's stats, completed quests, previously received input strings, game difficulty settings, current input string.


    Then, if your game receives 'How are you, friend?' input string, it displays output string 'Go away, animal!' doing something like this:

if (player is in zone1)
  if (player's charisma is equal to 1)
    if (player completed quest 'Have sex with Bishop's wife')
      if (previous player's replic was 'Hello, mister Bishop!')
        if (current input string icontains 'how are you')
          if (difficulty is equal to 'hardcore 18+')
            do_some_stuff(x)
           display("Go away, animal!")
          else
           do_other_stuff(y)
           display("Go away, retarded sickfuck!")

Just a bunch of simple if-clauses. Looks ugly. But this is the example of what is actually going on when you play any game - it receives some input signals and based on that signals and some constants and variables produces output:

if (variable1)
  if (variable2)
    ...
      if (variableN)
        do_simple_things()
        set_some_variables()
        display(x)

    Of course you will not write code like that. Well, if you are new to programming, you can even start with this code. In case of text-based games the amount of if-clauses is not huge. Good object oriented design will eliminate the need of this stuff and checks will be hidden. How to reduce the amount of explicitly-written conditions and write good object-oriented/meta abstract code for videogames? How to create your own game world model? What about roleplaying system? Items, objects interactions? Eventloop? Topics that are already covered in myriads of artices. But actually you can do that, and the process will be easy since it's just a text-based game. You'll still be able to focus on storytelling, replics and descriptions of things (usually it's 90% of interactive fiction development). And the development experience of doing these simple things yourself (even if you think that you produce worst code in the world) will be priceless. 

   What about natural language processing? I'll definetly write an article about some simple and useful algorithms you can use. The simplest thing you can do right now to improve players experience is to introduce synonyms checks and even simple regular expressions checks. That's right, son, don't just write 

    if inputString is equal to 'go north'

write 

    if inputString matches setOfRegexps

where setOfRegexps contains things that match 'I go north', 'I fuckin want to go north', 'I go to the north', 'I run north', 'I jump to the north'.

This is possible solution too:

    if inputString.icontains(mapOfSynonyms['go']) && inputString.icontains(mapOfSynonims['north'])

where mapOfSynonims is a map/any data structure that contains sets of your synonyms: [{'go', 'run'}, ['north', 'N'}]. Surprise - most of modern text-based games don't do that.

    Text-based game that understands 'hello' but can't understand 'hello, how are you?' fails one of the main tasks of text-based game - text processing. It was 'okay' 30 years ago. But now you need something more to impress players.

I didn't want a list of tutorials here again but, well, I feel I still need a list of resources for complete newcomers in gamedev world:

1.) Good python tutorial. Contains code for a text-based game with rooms and items.
2.) Question on stackexchange with example of game code with tons of if-clauses and tips for the ways of improving it.
3.) C++ article about writing of text adventure game from scratch.

    If you choose the way I described above - you can even say someday 'Hey, guys, I don't want text-only game anymore. I want to add awesome graphics and sound' - and you will do this, and the code you written for your text-based game will not be useless.

    That's all for now.

    Do you feel comfortable playing text adventure games with 'traditional' design? Maybe you faced problems with processing of different types of inputs with the same meaning in other types of games?

Monday, July 18, 2016

Modern text-based adventure games development #2: More problems


    In my previous post I stated some common problems you may face during the development of your game that contains text (wow, text?).

    Even if your game of this type has decent storyline, compelling characters and good writing (perfect example of bad writing is this blog. Joke, this blog is the best.), probability of success is still low. And if your writing is poorly done, cool landscapes and voice acting will not save you - because you have no graphics and no sound at all.

    I also mentioned visual novels - well, this can be a good choice for your state-of-the-art story/dialogs-driven game. Community of visual novels players is larger than interactive fiction players community (I am not even sure if IF-players community is alive) Add pretty faces of characters painted by decent artist, add sexy voice of your cousin and - voila - the best game of all time is ready.

    It's not that easy in real world. There are hundreds of visual novels with awesome arts and ourstanding voice acting - and with writing that looks like a writing of a retarded monkey translated via google (again, this blog) With stories that are so primitive that you think 'One more word and my brain is dead'. 

    So, good story, characters and dialogs are must-have for text-based game. Suppose that we already have it.

    What other kinds of problems do we have?


 - We have text only but still text component of the game is poor.


    Game understands 'go north' but fails to process 'lets go north'Game understands 'look' but can't do a shit when gets 'look around'

    It's not only poor natural language processing but the traditional mechanics of such types of games itself - it's a tradition in IF community to let player say 'go north' but forget about processing of other types of this phrase like 'I want to go North'. Just start to play Make it Good or any other interactive fiction game here and you will understand what I am talking about. 

    Your game has no graphics, no sound - and still it can't even process input strings that are slightly different from the strings that are direct orders - well, how can we say then that your game is a true text-based game?


 - Limitations of frameworks. 


    Almost every framework for IF development has typical and primitive understanding of what is a text-based game: such kind of a game must have rooms with a maximum of 4 doors or directions like north, south, west, east; such kind of a game must have 'look' and 'examine' mechanics; if you want to add roleplay to your game you better shoot yourself instead of doing this.
    These framework will not let you create your own game world - because creators of these frameworks surprisingly can't understand that 'text-based' doesn't mean 'has simple mechanics and primitive world model'.


 - No real characters. 


    That's right, guys, I reviewed Galatea recently and, actually, this is the best example of NPC in interactive fiction we have right now. Such a shame. 
    You can't say 'Hello, girl. How are you? What is your name?', you need to write ugly stuff like 'Ask X about Y' and repeat it again and again for any kinds of things you want to discuss.

    And it's not only the result of poor functionality of IF development frameworks.


Summary of the main problems I see so far:

1.) Poor natural language processing capabilities.

2.) Primitive gameplay.

3.) Primitive characters or even no 'real' characters at all.

    I think that modern text-based game must contain not only decent storytelling and writing, but also it must:

1.) implement game mechanics that is more complex than just 'man goes through some rooms and examines things'

2.) have at least one compelling NPC with opportunities to chat and opportunities to establish relationships.

3.) offer natural language processing (it's a text-based game so one of the main tasks is to process text, surprisingly for typical IF authors)

IF developer in a cruel world of gamedesign

    Moreover, good characters design is a must-have for every game in my opinion. It's one of the best means to bring some life into your game world. Through characters players can observe the effects of their actions on your game world in a natural way. 

    When a player comes back into your game and your character says 'Hello, bro. I am so glad you are here again!', your game makes a step forward to player's heart.

    That's all for now. Any other kinds of problems you see that I didn't even notice? Maybe story-driven text-based games are obsolete and it's useless to discuss such things?

Thursday, July 14, 2016

Modern text-based adventure games development #1: Problems


I decided to write yet another abstract post with my thoughts about text-based and interactive fiction games in general.

Am I really trying to think and to do something right now?

What are the problems of such type of games? What are the problems of developers who tries to create their state-of-the-art text-quests? I think this topic is very interesting. Moreover, almost every modern computer game contains some text, dialogs, lore, any kinds of descriptions so my monologue will not be only useful for developres of text quests and writers of interactive fiction.

You may take a look at some of my thoughts about typical examples of old and modern text-based games here: Galatea, Make it Good, Star Wars: Escape the Flagship.

So, you want to create your text-based adventure game. If you want to create it for yourself and your friends only (joke, developers of text-based games have no friends), then you just develop it. Then one or two guys in the world play it. Everybody is happy.

But what if you want to create something enjoyable for more than just one miserable person who plays your game only because he feels sorry for you (actually because he thinks you are a psycho who can do something bad if he will not check your game out)? 

You have a lot of problems then, son.

Because, guess what, text-based game is a text-based game and you are not a Hemingway. You need a good writings, you need a good plot, you need some compelling characters, you need good additional interesting mechanics ideas. Just go to textadventures.co.uk and launch some games - you will see a lot of problems. I hope. 

Some games there have good story but awful writings and awful English (even worse than mine). Some have perfect English but boring plot and obscure characters. Others have good plot and good English but simple and boring mechanics. Who is the audience of these games? Like with any other types of games, you have three main circles of players:

1.) Creator of the game.
It's not as bad as you may think (and even not that bad as I think). Some writers write novels just to read them after a year or so. Art for single person in the world is still an art.

2.) Creators of the games of similiar type.
Interactive fiction community is the best example in this case: they use similiar tools, they write their games, they play their games. Community is pretty closed and bounded (I am not saying this is bad).

3.) Usual gamers.
Mmmmm...usual gamers...Millions of players...success.

You can easily reach the audience of type 1 and 2, but what about type 3? Do you have some awesome pixelart pictures with landscapes and characters to impress those people? Do you have some insane chiptune soundtracks? Voice acting? Maybe you have beautiful animation?

No. You have text. Player writes some text as an input and the game displays some text as an answer. Nothing more.

Probably, you have a good story. Maybe some plot twists. Decent dialogs. But you can't show your compelling story or charming characters. You can tell something interesting about your game but it's not easy at all to impress people using text only. Especially in modern world of powerful graphics engines and pixelart freaks (I love them).

I will continue my analysis soon and will describe some features that are must-have for modern text-based games.

Do you think authors of visual novels have their answers for these questions? Visual novels have huge audience.

Wednesday, July 13, 2016

Overview of interactive fiction frameworks #3: Inform6


Our glorious jorney into amazing world of interactive fiction development tools and frameworks continues. Twine and Inform7 have fallen. Who is next?

Psypoke or Slowduck? Wtf?

Inform6. Yeah, Inform6, a father of Inform7.

Guess what, folks, Inform6 is better than Inform7 in many aspects, but still there is no reasons to use it. That's why this article is so short. Main things are here:

- Inform6 is an object-oriented programming language. Yeah, it's not like Inform7 which targets writers who knows nothing about software development.

- It's an old tool but guys like DavidKinder still support it. But, actually, they are all focused on Inform7 now.

- It has the same power as Inform7. Key features of Inform6 and Inform7 are almost the same.

- Inform6 code is more readable than pseudoenglish of Inform7 and actually does what you ask. I think Inform7 made a step back in this aspect. Guys are trying to get new audience or non-programmers.

That's all.

So, should you use Inform6?

If you are a writer who doesn't want to waste your time to learn programming language to create your simple games - use Inform7 or even Twine. 

If you are a software developer then you definetly don't need to learn yet another old and specific programming language to create your game. This tool was doing it's job well in the past. Now it's days are over, let's say 'thank you' and forget about it.

Again, list of good tutorials for those who still want to try Inform6:


I hope you will not use it.

As a bonus, take a look at the example of Inform6 source code with some definitions:

  Object Kitchen "Kitchen";
  Object Front_Door "Front Door";

  Object Living_Room "Living Room"
      with
          description "A comfortably furnished living room.",
          n_to Kitchen,
          s_to Front_Door,
      has light;

  Object -> -> Briefcase "briefcase"
      with
          name 'briefcase' 'case',
          description "A slightly worn, black briefcase.",
      has container;

Not that bad.

Enjoyable post is coming very soon.

Monday, July 11, 2016

Overview of interactive fiction frameworks #2: Inform7


I continue my analysis of interactive fiction and text-based games development frameworks in this article. Why do I need it? I am not only writer and manager, but I am also software developer so I need to know frameworks and tools that are already present on the market and that are already used by other fellow developers - I need to know their features, paradigms and ideologies as well as their limitations to produce better decisions and estimations.

My conclusion for Twine was 'this tool is for you if you want to create something simple and fast'. Now I am trying to find something advanced.

So, here's a brief (as always) overview of Inform7. Again, it's not a tutorial although I have a list of references to good tutorials for Inform7 below. This post will contain mostly criticism and high-level analysis of Inform features. Every mention of 'Inform' below corresponds to Inform7; Inform6 is completely different tool.


Golduck thinks he is smarter than Psyduck. He uses Inform7.

As the Inform's site says,

"Inform is a design system for interactive fiction based on natural language. It is a radical reinvention of the way interactive fiction is designed, guided by contemporary work in semantics and by the practical experience of some of the world's best-known writers of IF.

Sounds pretentious. I think the amount of those who knows what is interactive fiction is so small that the term 'best-known writers' sounds really naive and funny.

Let's get started. I decided to just install Inform and launch it. Usually it's one of the best practices to understand if particular application has good design. I see this:



It looks like Moscow metro map:



Start a new project.


What I see is the list with tutorials and documentation on the right side of the screen. This can be useful. I try to launch my project immediately:

Tons of text in error message. It says I need a room so let's create a room. You can create a room in Inform by writing 'X is a room' so I type 'Nest is a room' and launch my application again:


The way this tool allows you to define things is not common: it pretends you can do it in English. Let's try to print something like 'Nest is a room. Nest is beautiful.' and launch it again:


Tons of text. Was it hard to just print 'redefinition error' or 'double definition error'? The design of these error messages and the Inform itself says this tool was created for those who knows nothing about programming. I seek for advanced tools, but maybe it's just a first impression...

Also I see we can't really use English. We can use something that looks like English in a way that developers of Inform defined for us. 

We have a place - now let's add a character: 

There is a Crow in the Nest.


As we can see, Inform has predefined sentences like 'You can see X here'. I didn't even asked to use it. Maybe we can redefine this sentence? I suppose I can overwrite output strings like this when player enters into particular room writing something like 'when X enters Y print Z'. 

Let's add some objects to our scene: 

Nest is a room.
There is a Crow in the Nest.
There is a Bottle of Pepsi in the Nest.
There is no Bottle of Pepsi in the Nest.

I added two contradictory statements.


Inform didn't understand it - well, it's not so important, but still.

I noticed that Inform not only has predefined sentences which describe things but also it has some predefined actions. I can take that Crow right now: I launch the game, enter 'take Crow' and my game answers: 'Crow taken'. Wow. Now 'drop the Crow': 'Dropped'. Funny.

I can change this behavior adding this lines of 'code':

After taking the Crow:
    say "Taken damn Crow, son"

Now if I enter 'take Crow' game will show my message. Let's specify that Crow is just a name of a man and launch the application again:

Crow is a man.




Mettlesome tool. 'I don't suppose the Crow would care for that.' So, my statement 'After taking the Crow:...' doesn't work anymore? That's right, Inform decided I can't take a character and refused to execute my line of code (which is actually simple if-else construction that you can find in any programming language). It's a bit strange. I searched for a solution and found this: you can use 'Instead of' construct:

Instead of taking the Crow: say "You can't take the Crow - it's a man."

Let's polish our code a bit and add an opportunity to talk with mister Crow and the description of our Nest:

Nest is a room. "Actually, it's not a room, it's a nest"

There is a Crow in the Nest.
There is a Bottle of Pepsi in the Nest.
Crow is a man.

After asking the Crow about "parrot":
    say "You talk about parrots. It's the best conversation in your life."



It works, as you can see. I want to add yet another location with additional character:

Tree is a room. "Actually, it's not a room. It's a tree."

Tree is north of Nest.
There is a Parrot in the Tree.
Parrot is a man.

Now if I sit in the Nest and type 'go north' game transports me to the tree so I can see mister Parrot there. I also can bring my Pepsi as a present to fellow Parrot. Predefined actions. Great.

Final version of Inform 'code' which produces two connected rooms with two characters and one item:

Nest is a room. "Actually, it's not a room, it's a nest"

There is a Crow in the Nest.
There is a Bottle of Pepsi in the Nest.
Crow is a man.

Instead of taking the Crow: say "You can't take the Crow - it's a man."

After asking the Crow about "parrot":
say "You talk about parrots. It's the best conversation in your life."

Tree is a room. "Actually, it's not a room. It's a tree."
Tree is north of Nest.
There is a Parrot in the Tree. "Angry Parrot".

Parrot is a man.

Actually, this pretty much describes everything what Inform is. If you have some development experience (enterprise, indie,...) you already see a lot of 'interesting' things.

Inform hides what is actually going on so I'll rewrite it via normal programming language like C++ using hypothetical Inform library for this language:

Room Nest(LOC(1, "Nest"), LOC(2, "Actually, it's not a room, it's a nest"))

Character Crow(LOC(3, "Crow"));
Crow.addAction(LOC(11, "take"), LOC(4, "You can't take the Crow - it's a man."), ActionTypes::SimplePrint);

Item BottleOfPepsi(LOC(5, "Bottle of Pepsi"));

Nest.add(Crow);
Nest.add(BottleOfPepsi);

Room Tree(LOC(6, "Tree"), LOC(7, "Actually, it's not a room. It's a tree."));
Nest.connect(LOC(12, "north"), &Tree);

Character Parrot(LOC(8, "Parrot"), LOC(9, "Angry Parrot"));
Parrot.addConv(LOC(10, "You talk about parrots. It's the best conversation in your life."));

ConversationGroup Conv;
Conv.add(Nest, CrowBottleOfPepsi, Tree, Parrot);

MovableGroup Movable;
Movable.add(BottleOfPepsi);

Game(Conv, Movable).launch();

Pretty simple, right? Well, if you are familiar with at least one programming language. 

It's not only simple, it's also more flexible. When you see what is actually going on you can change the behaviour in the way you want. I mean, you have classes. You have objects. You can completely change the behaviour of classes. You can easily take the Character class as a base and override any method you want. You can add your subclasses easily. You can rewrite the entire object model of the game.

You cannot do it easily with Inform. There is no normal object oriented model in it - this programming language is actually rule-based with all the disadvantages. Inform supports inheritance and some other kinds of abstractions but in a very unnatural way.

Inform incorporates basic world model with default behavior. Characters, items, zones, basic actions. Almost everything has default description strings and default action strings. Sometimes you can rewrite default behaviour using constructions like 'Instead of', but most of the time you don't want to change anything in Inform because it's hard and usually your solutions aka adhocs aka crutches look really ugly. Changes in the world model of Inform are not recommended.

You also may notice strange LOC symbols near each strings in my example. That's right, guys, I indicated localization functionality: LOC(identifier of localization resource, default value).

Inform doesn't support localization.

Here is a brief summary:

- Inform targets people who knows nothing about software and game development. If you are not a software developer (and you are not planning to become a software developer in your future) you can use this tool and skip the text below.

- Inform is a bit more advanced if we compare it with Twine.

- Inform contains a lot of predefined features - these features can be useful if you are a beginner.

- The world model of your game is already defined for you in Inform as well - and changes in this model are not recommended (hard to implement, look ugly).

- The world is defined, the model is incorporated - so you can't actually create a game that is not an interactive fiction and text-based one using Inform. Learning Inform is a complete waste of time if there's a possibility of you switching your mind in this way: 'Hmm, I just finished my awesome text-based game and now I want to add images of characters, sounds and any kind of advanced gameplay'. Only text-based games. Dead end.

- Real things are hidden under the skin that 'looks like English'. In my opinion this is the worst possible design solution. Differences between the code and simple text are washed away. Reading of such kind of code is a complete torture - especially if you write something that is more advanced than bunch of one-liners. You need to understand where is real English and where is Inform7. I don't even want to discuss debugging here.

- Inform is a rule-based language with all the disadvantages. Actually it doesn't look like a programming language, it looks like a simple 'English-language-like' wrapper over programming language with some predefined features for writing specific kinds of interactive fiction games.

- Yeah, with Inform you can publish your game fast on your website (as well as with Twine).

I think you still can use this tool if you want to create something simple and fast and you already understand that Twine is unsuitable in your case. An opportunity to create and publish a game instantly can be useful for newcomers.

As I promised, here is the list of comprehensive tutorials for Inform7:


1.) Inform7 for programmers guide.

2.) Comparison of Inform7 and TADS3 (other tool for interactive fiction) A lot of useful information.

3.) Blog of a girl with Inform7 tutorials.

4.) Getting Started with Inform7 tutorial

5.) Inform7 documentation, also available via the application itself.


Do I underestimate Inform7? Any features of this tool you enjoy?