Thursday, August 4, 2016

Another Rulebook Post (Inform 7)

I wrote last week about getting over the fear of rulebooks in Inform 7, specifically by not using the all-powerful INSTEAD to accomplish everything.  After I read over the post, I remembered one of my specific hangups using rulebooks occurred because I was over-thinking the process: how does Inform know how my additional rules work in order?  How does Inform know what order the rules should go in? Don't I need to write them very specifically so Inform and the compiler don't get confused?

The short answer is not really.  Beyond a few minor sequencing points when polishing the text output, Inform does not care where in the source text we write our rules. And the rulebooks consider every rule in them unless a rule explicitly tells it to stop (with an INSTEAD or "stop the action.")

Imagine creating a shopping list. Unless we're extremely familiar with the grocery store layout, we'll write a list as items occur to us, possibly over a period of time or several days. We might make a little effort grouping frozen foods and produce together since we know they are in the same general area within the building, but as we shop, we're going to run down the list in each location. And theoretically without any specific handling issues, the items in our cart will stack so that the last thing we inserted into it will be the first thing checked out by the cashier, unless we decide to bump something onto the conveyor belt first, perhaps because it's heavy or frozen.

Remember that the source text is only feeding information to the compiler which arranges it for its own use. Any BEFORE rule you write goes into the Before rulebook, and all "before" rules will run before any CHECK rules.  In many cases it doesn't matter what order the rules run in; if the player cannot pick up a boulder for one reason, it doesn't matter whether they also can't pick it up for another reason.

In general, we are encouraged to avoid player messages until the REPORT stage after everything is happened. Sometimes it's nice though to give the player some feedback along the way, such as if the author/parser has taken a shortcut action for them, or to explain why an action failed.

Gauntlets of Hercules is carried by the player. It is wearable. A golden fleece is carried by the player.

some river sticks is a thing. 

Rocky Valley is a room. 

A giant boulder is in Rocky Valley. "A giant boulder here blocks the way north.". The description is "The boulder is taller than you, and more than likely not movable by mortal means." 

Check taking giant boulder (this is the really it's more awkward than heavy rule):
  if the player does not wear the gauntlets of Hercules:
    say "Shyeah, right. You're just going to pick that     boulder up and carry it with you. Har!" instead.

Before taking giant boulder:
  if the player wears gauntlets of Hercules:
    if giant boulder is not handled:
      say "You wiggle your fingers in the gauntlets given to you by the mysterious old lady. You hope she wasn't having you on about their magic powers." 

Before taking giant boulder (this is the can't carry anything and the boulder rule):
  if the player carries something:
    say "(first dropping everything else you're holding: [a list of things carried by the player].)[paragraph break]";
    now everything carried by the player is in the location. 
Carry out taking giant boulder:  if river sticks is off-stage:    now river sticks is in the location;    say "Some sticks weathered by the river are dislodged from the side of the boulder as you lift it."
Carry out taking giant boulder (this is the hard work requires loud noises rule):
  if giant boulder is not handled:
    say "HUUUERRRRRGHHHH--hey, it's not that heavy after all and you needn't have made such a noise before lifting it." 


Report taking giant boulder:
  say "You've got the boulder, but it takes both of your arms, and you won't be able to carry anything else. It's more awkward than it is heavy." 

Check taking something when the player carries giant boulder:
  say "If you reach for [the noun], you'll need to put down the boulder first." instead.
I defined these rules completely out of order as far as the actual logical sequence this would all occur in, but let's try it:

Rocky Valley
A giant boulder here blocks the way north.

>take boulder
(first dropping everything else you're holding: Gauntlets of Hercules, a golden fleece.)

Shyeah, right.  You're just going to pick that boulder up and carry it with you.  Har!

Hmn.  That technically worked, but it didn't make a lot of sense to make the player drop everything when they aren't even going to be able to actually lift the giant boulder. Let's specify the rule order a bit. I want the snarky message to be the only thing the player sees if they aren't wearing the gauntlets. That rule already ends with INSTEAD so let's tell Inform to put it "first" in the Check Taking* rulebook. 

First check taking giant boulder (this is the really it's more awkward than heavy rule):
if the player does not wear the gauntlets of Hercules:
say "Shyeah, right.  You're just going to pick that boulder up and carry it with you.  Har!" instead.

That way, any other rules I think of and write later, even in the future, won't even be considered until the player is wearing the gauntlets.

I also need to change my "can't carry stuff and the boulder" rule since it's a BEFORE rule that will always occur before a CHECK rule.  It actually makes more sense as CARRY OUT since there's no reason for the player to drop everything until they are actually going to lift the boulder. I will also tell Inform to put that "first" in the CARRY OUT rulebook since I don't want the player to make their mighty grunt and then decide they have to drop everything they have in their hands:

First carry out taking giant boulder (this is the can't carry anything and the boulder rule):
  if the player carries something:
  say "(first dropping everything else you're holding: [a list of things carried by the player].)[paragraph break]";
    now everything carried by the player is in the location.


Rocky Valley
A giant boulder here blocks the way north.

>take boulder
Shyeah, right.  You're just going to pick that boulder up and carry it with you.  Har!

There, that's much better. Continuing...

>wear gauntlets
You put on Gauntlets of Hercules.

>take boulder
You wiggle your fingers in the gauntlets given to you by the mysterious old lady. You hope she wasn't having you on about their magic powers.

(first dropping everything else you're holding: a golden fleece.)

Some sticks weathered by the river are dislodged from the side of the boulder as you lift it.

HUUUERRRRRGHHHH--hey, it's not that heavy after all and you needn't have made such a noise before lifting it.

You've got the boulder, but it takes both of your arms, and you won't be able to carry anything else. It's more awkward than it is heavy.

Taken.

>take fleece
If you reach for the golden fleece, you'll need to put down the boulder first.

>drop boulder
Dropped.

>take fleece

Taken.

Once again, that worked, but we'd like the text of the player grunting to happen before they lift the boulder and reveal the very important river sticks they will need later.  Once again, we tell Inform what rule should come first:

First carry out taking giant boulder (this is the hard work requires loud noises rule):
if giant boulder is not handled:
say "HUUUERRRRRGHHHH--hey, it's not that heavy after all and you needn't have made such a noise before lifting it." 

>wear gauntlets
You put on Gauntlets of Hercules.

>take boulder
You wiggle your fingers in the gauntlets given to you by the mysterious old lady. You hope she wasn't having you on about their magic powers.

HUUUERRRRRGHHHH--hey, it's not that heavy after all and you needn't have made such a noise before lifting it.

(first dropping everything else you're holding: a golden fleece.)

Some sticks weathered by the river are dislodged from the side of the boulder as you lift it.

You've got the boulder, but it takes both of your arms, and you won't be able to carry anything else. It's more awkward than it is heavy.

Still not quite right.  The grunt happened, but then the player doesn't drop everything until after that, which is still the wrong order.  Let's check the source text:

First carry out taking giant boulder (this is the can't carry anything and the boulder rule):
if the player carries something:
say "(first dropping everything else you're holding: [a list of things carried by the player].)[paragraph break]";
now everything carried by the player is in the location.
Carry out taking giant boulder:  
if river sticks is off-stage:    
now river sticks is in the location;    
say "Some sticks weathered by the river are dislodged from the side of the boulder as you lift it."
First carry out taking giant boulder (this is the hard work requires loud noises rule):
if giant boulder is not handled:
say "HUUUERRRRRGHHHH--hey, it's not that heavy after all and you needn't have made such a noise before lifting it." 

So we've defined two "first" rules. What's happened here is reliant on source text order.  We told Inform to put the "can't carry anything and the giant boulder" rule first, which it did.  Then we told it to put the "hard work requires loud noises" rule first also.  Since our previous rule is already the first rule in the rulebook, it is bumped forward a step to make room and let the other be first.

One solution is to switch the order of the rules in the source text.  However, if we write any other rules affecting the boulder later they might get out of order again. The other way is just to combine them into the same rule so they run in correct order as a unit:

First carry out taking giant boulder (this is the drop everything before heaving the boulder rule):
if the player carries something:
say "(first dropping everything else you're holding: [a list of things carried by the player].)[paragraph break]";
now everything carried by the player is in the location;
if giant boulder is not handled:
say "HUUUERRRRRGHHHH--hey, it's not that heavy after all and you needn't have made such a noise before lifting it."

For good measure, we can make sure our message about river sticks runs "last".

Last carry out taking giant boulder:  
if river sticks is off-stage:    
now river sticks is in the location;    
say "Some sticks weathered by the river are dislodged from the side of the boulder as you lift it."

>take boulder
Shyeah, right.  You're just going to pick that boulder up and carry it with you.  Har!

>wear gauntlets
You put on Gauntlets of Hercules.

>take boulder
You wiggle your fingers in the gauntlets given to you by the mysterious old lady. You hope she wasn't having you on about their magic powers.

(first dropping everything else you're holding: a golden fleece.)

HUUUERRRRRGHHHH--hey, it's not that heavy after all and you needn't have made such a noise before lifting it.

Some sticks weathered by the river are dislodged from the side of the boulder as you lift it.

You've got the boulder, but it takes both of your arms, and you won't be able to carry anything else. It's more awkward than it is heavy.

Taken.

Almost there.  We want to get rid of that "Taken" message which is the standard report taking response.  We can do that by changing our report taking giant boulder rule to an "after" taking giant boulder rule.  AFTER rules occur before report rules, and will naturally stop and override them (unless appended with "continue the action).

After taking giant boulder:
say "You've got the boulder, but it takes both of your arms, and you won't be able to carry anything else. It's more awkward than it is heavy." 

HUUUERRRRRGHHHH--hey, it's not that heavy after all and you needn't have made such a noise before lifting it.

Some sticks weathered by the river are dislodged from the side of the boulder as you lift it.

You've got the boulder, but it takes both of your arms, and you won't be able to carry anything else. It's more awkward than it is heavy.

>

As things get more complicated, it is actually possible to create a specific rulebook for a complicated action--say a magic box that transforms items into other items.  For this type of information, it's best to read the entire section about rulebooks in the Inform documentation.  There are also many more useful rulebooks beyond what I've only scratched the surface of here.


---

Thursday, July 28, 2016

Instead of Instead (Inform 7)

Inform 7 allows an author to accomplish things in many different ways.  It's easy enough to make a dungeon full of rooms and doors and containers and treasures, but if we go much further beyond that, we have to work with creating rules.

All actions in Inform have rulebooks which roughly correspond to phases of time it takes to perform the action.  The major three are

  • CHECK - This is where Inform decides if an action can be accomplished.
  • CARRY OUT - This is where the actual mechanics of the action take place.
  • REPORT - After everything is done, this is where the parser can print a message confirming what has taken place.
Three other rulebooks are built-in:
  • BEFORE
  • AFTER 
  • INSTEAD

BEFORE and AFTER slot where you'd expect, but INSTEAD is probably the most powerful and most mis-used due to that inherent power.  New authors often find the check/carry out/report sequence confusing at first, and will latch onto INSTEAD like Dr. Who's sonic screwdriver to accomplish everything. Why learn a whole handful of rulebooks when you only need one?

The reason is INSTEAD essentially is an override that relinquishes the parsing of a command over to the author. When one tells Inform "Instead of doing this action..." the parser won't bother checking anything and will use the author's specific rule.  Also INSTEAD overrides every other rule including other INSTEAD rules, defaulting to the most specific for a situation.

Suppose all flowers cause wooziness, but certain types have added effects:
Garden is a room.
A flower is a kind of edible thing.  A rose is a kind of flower.  A daisy is a kind of flower.  A lily is a kind of flower.  Understand "flower" as a flower.
There are four roses in garden.  There are six daisies in garden.  There are three lilies in garden. 
Instead of eating a flower: say "It tastes bitter and you feel woozy." 
Instead of eating a rose: say "The rosy scent tickles your nose."
Instead of eating a daisy: say "You feel light-headed."


Garden
You can see four roses, six daisies and three lilies here.
>eat flower
Which do you mean, a rose, a daisy or a lily?
>lily
It tastes bitter and you feel woozy.
>eat rose
The rosy scent tickles your nose.
>eat daisy
You feel light-headed.
>l
Garden
You can see four roses, six daisies and three lilies here.


You'll notice we aren't getting the default message for "flowers" in every case because the more specific Instead rule for roses and daisies override since they are more specific. Also problematic is that even though flowers are declared "edible" they aren't disappearing like standard edible objects because Inform has relinquished control to the author, and our INSTEAD rule doesn't handle the behavior for edible objects. So lets make this change:
Instead of eating a flower:
   say "It tastes bitter and you feel woozy.";
   remove the noun from play.
Garden
You can see four roses, six daisies and three lilies here.
>eat lily
It tastes bitter and you feel woozy.
>look
Garden
You can see four roses, six daisies and two lilies here.
>eat rose
The rosy scent tickles your nose.
>look
Garden
You can see four roses, six daisies and two lilies here.
So our INSTEAD with included eating rules is only working on lilies, which don't have more specific Instead rules affecting them. An enterprising new author usually here will go "No problem, I can write this into every instead rule."  But over the course of even a moderate-sized game this will grow tedious--especially if we want to write other rules that affect flowers, and we'll have to keep up and update every single rule:
Sickness is a number that varies.
Instead of eating a flower:
say "It tastes bitter and makes you feel woozy.";
increase sickness by one;
if sickness is greater than one:
say "You don't feel so good after that meal.";
if sickness is greater than two:
end the story saying "Flowers, while beautiful, have their downsides.  You have been poisoned!"

Instead of eating a rose:
say "It tastes bitter and makes you feel woozy.";
say "The rosy scent tickles your nose.";
increase sickness by one;
if sickness is greater than one:
say "You don't feel so good after that meal.";
if sickness is greater than two:
end the story saying "Flowers, while beautiful, have their downsides.  You have been poisoned!"

Instead of eating a daisy:
say "It tastes bitter and makes you feel woozy.";
say "You feel light headed.";
increase sickness by one;
if sickness is greater than one:
say "You don't feel so good after that meal.";
if sickness is greater than two:
end the story saying "Flowers, while beautiful, have their downsides.  You have been poisoned!"

The author is doing more work than they need to bypassing the parser with INSTEAD. Say we want flowers to eventually poison the player.  Every rule would need to do the work of the parser. While the before/check/carry out/report/after sequence of rulebooks seems daunting, it actually makes life easier:
Garden is a room.
A flower is a kind of edible thing.  A rose is a kind of flower.  A daisy is a kind of flower.  A lily is a kind of flower.  Understand "flower" as a flower. 
Sickness is a number that varies. 
There are four roses in garden.  There are six daisies in garden.  There are three lilies in garden.
After eating a flower: [AFTER will override the normal "You eat the thing. Not bad." report message for edible things]
say "It tastes bitter and makes you feel woozy."; 
First after eating a rose: ["First after" puts this message at the beginning of the After rulebook]
say "The rosy scent tickles your nose.";
continue the action. [So both messages will print as an AFTER will normally stop] 
First after eating a daisy:
say "You feel light-headed.";
continue the action. 
[It's good to name your rules]
Carry out eating a flower (this is the flowers are poisonous rule):
increase sickness by one.
 [An author needn't pack everything into a single rule.]
Carry out eating a flower (this is the consequences of eating flowers rule):
if sickness is greater than one:
say "You don't feel so good after that meal...";
if sickness is greater than two:
end the story saying "Flowers, while beautiful, have their downsides.  You have been poisoned!";
Garden
You can see four roses, six daisies and three lilies here.
>eat lily
(first taking the lily)
It tastes bitter and makes you feel woozy.
>l
Garden
You can see four roses, six daisies and two lilies here.
>eat daisy
(first taking the daisy)
You don't feel so good after that meal...
You feel light-headed.
It tastes bitter and makes you feel woozy.
>look
Garden
You can see four roses, five daisies and two lilies here.
>eat rose
(first taking the rose)
You don't feel so good after that meal...


    *** Flowers, while beautiful, have their downsides.  You have been poisoned! ***
 
INSTEAD rules are very powerful and good for limiting the player from doing foolish things or tying up loose ends of standard responses:
Instead of jumping, say "Out, damned spot!"
Instead of smelling, say "Your sinuses have been acting up, so that sense is currently nonfunctional for the time being." 

And even this type of power can be safely folded into the CHECK rulebook for the specific action:
Check eating a flower (this is the great power equals great responsibility rule): say "You shouldn't be eating flowers. Who knows if they are poisonous?" instead
-----
Thanks to the tireless denizens of the IntFiction.org forums where great advice for programming IF in Inform 7 is best obtained.  I have a website http://hanonondricek.wixsite.com/pyramidif









Wednesday, July 20, 2016

I am the Baker of Shireton/And I bake bread because baking is fun...

Now to find Bob the Hobo...
So I made a loaf of bread last night and...hunh.  How did that get in there?  It must have been that other version of me stashed in the back room...
















(I added some space so this doesn't crash with the preceding article on Planet IF)

Monday, June 27, 2016

History has been [REDACTED]


Redactor: War is peace. Freedom is slavery. Ignorance is strength.
I'm surprised no one before this has thought to make a game out of George Orwell's 1984. The novel includes a very game-able scenario in that the main character's profession is to change printed publications--and therefore history--by editing news stories to reflect positively on the government and slander its enemies.  This dystopian concept is actually frighteningly more plausible now thanks to the internet.  Witness Wikipedia, where well-intentioned editors often constantly battle to prevent vandals from changing details about real-world events and personalities, putting their own thumbprint on general perception.

Redactor casts the player as an employee of the Ministry of Truth in the Records Department ("Minitrue RecDep" in 1984's prescient stylization preference of eliminating extraneous words and syllables) and presents a slim time limit and rules of how a news article needs to change:

You will have 25 seconds to rectify a newspaper article so that it reports the truth:
- We have always been at war with Eurasia, and Eastasia has ever been our ally.

The player is audited a couple of times to review their performance. And...then it ends all too soon. The game is well presented and polished, and has the same sort of atmosphere as Papers, Please (which also cribs from Orwell, and chillingly satirizes Cold War bleakness.)

I wish this game could have been longer and taken its premise further.  Gameplay essentially consists of scanning an article and clicking on everything that is a hidden hyperlink before the very quick time limit expires. This feels like a prototype for a bigger game that could have done more with Twine cycling links and some red-herring links that are correct to begin with and shouldn't be changed.  As it stands, there are no wrong choices as long as you find every link, so it's more of a speed scanning click fest. I suspect the time limit is purposefully set razor-thin to present an actual challenge; in many cases the time limit was barely enough for me to even skim the entirety of the well-written in-world articles, which is a shame.  I'd have loved for the timer to run longer and to have had a chance to actually read and comprehend the articles for context and spent time figuring out how to comply with an ever-changing, increasingly difficult spaghetti-bowl of conflicting rules. Then again, that's also how it works in Papers, Please.

This is definitely worth a look.  The credits list a designer and five writers, and was created as a social engagement promotion for a stage production of 1984. Sadly, there are no photos or information of this production on the current website linked in the credits.  [Was it REDACTED???] Theater websites rarely advertise past shows so this is understandable, but would have been a neat easter egg for completing the game.

Despite some missed opportunities in gameplay, what's offered is very well implemented and polished, uses Twine in unique fashion, and provides a brief glimpse into the reflected eye of Big Brother in the monitor watching over your shoulder.
---
I over-design flashy webpages for my rather under-developed IF games at hanonondricek.wix.com/pyramidif

Monday, June 20, 2016

Two Quick BOYD Discoveries

I didn't think I'd be interested in the non IF stuff, but some of it has been eye-opening.

First is How to Kill a Project by Wertle, a game designer named Lisa, who has created a biographical Twine which explains some of her experience with creating and abandoning games.  A few of these are actually embedded in the Twine and playable.  Favorites are Death Jeopardy and Imperfection.

It's interesting to see how certain game systems can be embedded in a choice-based story and inspires ideas such an interactive game map or a small physical puzzle or a graphical inventory.  The author's backstory is also interesting and this is an amazing use of Twine.

Watch your ankles on those stairs.
The second is not IF related at all, but has a very cool Portal vibe and an interesting concept.  Conflux's conceit is that certain 3D physical structures are incomplete until you view them from the correct perspective.  There isn't any documentation, but standard 3D controls, WASD-space-mouselook work, and left click will pick up an object.  This is obviously unpolished as there isn't a lot of feedback until you find the right precise spot to solidify a structure, and it is sometimes hard to tell if what you're seeing is "right" or not.

This is still a unique concept, a step on the way to the non-euclidean game I've always wanted that allows physical exploration of Escher-esque spaces.  This isn't it, but I liked it.  It's Mac only.
---
I use WYSIWYG to make it look like I know how to make a website at http://hanonondricek.wix.com/pyramidif

Saturday, June 18, 2016

Bring Out Your Dead Jam

Lots of popular IF heavy-hitters have posted unfinished works to Emily Short's unusual Bring out Your Dead jam which lets authors put unfinished and "dead" projects on display.

The jam is only on for about a week, so I don't know if these titles will be available or disappear afterward, so be sure go check out early experiments by your favorite IF figures such as Emily Short, Andrew Plotkin, Sam Kabo Ashwell, Caleb Wilson, A. Deniro, Carl Muckenhoupt, David Cornelson, Mathbrush, Laura Michet, Bruno Dias, Catacalypto, and possibly more as the six days of the jam progress.

The jam is not restricted to IF so there are some other interesting game experiences on display.  Many other people are blogging about this, so I won't go on in detail.

Thursday, June 9, 2016

Graphic Adventure Sale on Humble Store

I clicked on an email notification for the Humble Store that was slightly misleading: "Choose Your Own Adventure Bundle," thinking it would have discounts on some Choice of Games (which are already ridiculously reasonably-priced) or things like 80 Days (which I already own, but I was interested to see a current discount price.)  On the site it's actually "Build Your Own Adventure Bundle" of graphical adventures which makes more sense.

Humble is offering some wonderful classic and remastered adventure games for a few dollars each. If you haven't experienced some of these in the past, it's well worth checking out, especially for Broken Age, and remastered versions of Grim Fandango and the original Gabriel Knight.  All of these on offer are available for Mac and Windows, several are available for Linux, and Broken Sword 5 also offers an Android port.

--Edited to add:  This sale will end on the 12th or 13th of June by my rough estimation, based on your time zone.  Countdown clocks are on each game on the website.

Matt also comments below that you can get 80 Days as well as other Inkle games, and Cibele, and Her Story among others in the Humble Narrative Bundle which is still on for four more days which is an excellent deal where you choose your own price for the entire lot.  This ends approximately June 14th based on your time zone.
----
I have a website at http://hanonondricek.wix.com/pyramidif.