Experiment 2 — 1 of 1

Aaron Reed

Release 1

"Experiment 2" by Aaron Reed

[This is part 2 of an irregular series of blog posts about playable experiments in Inform 7. It is compileable Inform 7 source code. Part 1 is available here: http://aaronareed.net/if/ex1/

For a more nicely formatted version of the experiment, and a version playable in your web browser, visit http://aaronareed.net/if/ex2/

Let's set up that playable online business.]

Release along with a website, the source text, and an interpreter.

[In this experiment, we're going to play with dynamic rules. We need a recently published extension to do this most effectively.]

Include Ignored Rules by Ron Newcomb.

[Each action in Inform has a list of rules, the "check" rules, which determine whether or not it is allowable to do something. For instance, we might create a relation and action to represent marriage:]

Marriage relates various people to each other. The verb to marry (he marries, they marry, he married, it is married, he is marrying) implies the marriage relation. The verb to be married to implies the marriage relation.

Marrying someone to is an action applying to two visible things. Understand "marry [any thing] to [any thing]" as marrying someone to.

[...and then create a list of rules encoding a set of societal norms.]

Check marrying someone to (this is the can't marry yourself rule): if the noun is the second noun, instead say "People can't be married to themselves."

Check marrying someone to (this is the can marry only one person at a time rule): if the noun is married to someone or the second noun is married to someone, instead say "One of those people is already married."

Check marrying someone to (this is the can't marry those of your own gender rule): if ( the noun is male and the second noun is male ) or ( the noun is female and the second noun is female ) , instead say "People cannot marry others of their own gender."

[Assuming there is no violation of these rules, the action succeeds:]

Carry out marrying someone to: now the noun is married to the second noun. Report marrying someone to: say "Pronounced."

[One can imagine a story, though, which involves meddling with these restrictions. First, let's create a variable to hold a rulebook of interest.]

The active rulebook is a rulebook variable. The active rulebook is the check marrying someone to rules.

[Now let's give the player a way to review the law. (Perhaps self-indulgently, we tweak the text of the displayed rules to give them a more authoritarian weight.)]

Understand "laws" as listing the laws. Listing the laws is an action applying to nothing.

Carry out listing the laws:

let rule name be indexed text;

let law number be 1;

repeat with mandate running through the active rulebook:

if mandate is the little-used do nothing rule, next;

now rule name is "[mandate]";

replace the text " rule" in rule name with "";

replace the text "can't" in rule name with "shalt not";

replace the text "can " in rule name with "shalt ";

replace the text "your" in rule name with "thy";

say " [law number]. Thou [rule name].";

increase law number by 1.

[Now we need a way to upset the status quo. While the parser won't recognize rule names, we can use the order they're listed as a shortcut.]

Striking is an action applying to one number. Understand "strike [a number]" as striking.

Carry out striking:

let law number be 1;

repeat with mandate running through the active rulebook:

if mandate is the little-used do nothing rule, next;

if law number is the number understood:

ignore mandate for the active rulebook;

increase law number by 1.

[Now we have a way to strike out rules which we dislike. (Adding rules back in would present more challenges which we'll omit here for brevity.)

Let's set up a very basic scenario for testing:]

Stage is a room. Alan and Bob and Carl and Dan are men in Stage. Enis and Francie and Gianna and Harriet are women in Stage.

After examining a person when the noun is married to something: say "[The noun] is married to [the list of things which are married to the noun]."

[Two closing thoughts. First, we can easily change the value of the active rulebook variable to any other check rulebook (such as the check taking rules) to meddle (perhaps disastrously) with the physical as well as societal laws of the story world. And second, there's nothing to stop us making similar rules for the actions we're using to meddle:]

A person is either royal or peasant. The player is royal [for now?]. Check an actor striking (this is the can only strike out laws if one is royalty rule): if the actor is not royal, instead say "Only a royal can do that."

[Here are some other commented out marriage rules to play with:]

[Check marrying someone to (this is the can't marry people of different first letters rule): if character number 1 in printed name of noun is not character number 1 in printed name of second noun, instead say "People cannot marry outside their first letter."]

[Check marrying someone to (this is the can't marry people one cannot see rule): if location of noun is not location of second noun, instead say "People cannot marry those not in the same location."]