Inform 7 [the noun] in description of location - inform7

I'm trying to put "stranger man" instead [the noun]. In this piece of code:
Rule for listing nondescript items: do nothing.
A staircase is a kind of door. A staircase is usually open.
A staircase is seldom openable. The ladder is a staircase.
The ladder is above the Entry and below the Reception.
The description of Entry is "You see ladder forward.".
A stranger man is man in the Reception.
The description of Reception is "You see [the noun] at the reception. On the left side is corridor.".
In describing the location, I see "the up" instead of "the stranger man". But after attack and remove the noun from play;, I see "nothing" - all right.
Entry
You see ladder forward.
>up
Reception
You see the up at the reception. On the left side is corridor.
>attack man
You attack the stranger man, causing 5 points of damage!
The stranger man attacks you, causing 7 points of damage!
>attack man
You attack the stranger man, causing 8 points of damage!
The stranger man attacks you, causing 7 points of damage!
>attack man
You attack the stranger man, causing 6 points of damage!
The stranger man attacks you, causing 2 points of damage!
>attack man
You attack the stranger man, causing 4 points of damage!
The stranger man attacks you, causing 8 points of damage!
>attack man
You attack the stranger man, causing 10 points of damage!
The stranger man die, you win!
>attack man
You can't see any such thing.
>look
Reception
You see nothing at the reception. On the left side is corridor.
why is this happening?

"The noun" is a global variable referring to whatever the main object of the previous action was, which in this case is the direction "up". When you looked the second time, it tries to access the previous object, but because the parser failed the result is the null object, "nothing".
I'm not too sure what you're trying to do, but trying to refer to a man who won't always be there in the room description like that is almost certainly the wrong approach. If what you're trying to do is to list the man before the exits, then the Room Description Control by Emily Short extension might help.

Related

Getting a simple reply from a character in Inform 7

I have a non-player character in an Inform 7 Interactive Fiction story that I would like to get a simple reply from. The character is a robot doctor. When you get on the exam table the robot doctor holds out a tongue depressor and asks you to say, "Ah." I would like the character to say something when the player types, "say ah" but so far it's not working.
Here is my code thus far:
The exam table is a supporter in the Med Bay. It is fixed in place and enterable.
In the Med Bay is a person called Auto-Doc.
After entering the exam table, say "A number of bright lights embedded in an overhead panel bathe you in a cold, white light. A panel in the wall opens and an auto-doc trundles forth on a three-wheeled base. Clutching a tongue depressor in its mechanical grip, a small speaker hidden within crackles with the words 'Say, ah.'"
After speaking in the presence of the Auto-Doc, say "Mmm. Mm-hmm. Very interesting."
The last line is causing the compiler to throw an error, but I am unable to figure out what to use. I've tried Instead of speaking, After telling the Auto-Doc something, After saying ah in the presence of the Auto-Doc, and so far nothing is working.
Any hints as to how I can get the Auto-Doc to say something after the player types "say ah"? I'd even be happy with the Auto-Doc replying the same way no matter what the player says.
Here's a handy tip: command ACTIONS while playing the game in the IDE to see the action name when you type commands.
>actions
Actions listing on.
>say ah
(to Auto-Doc)
[answering Auto-Doc that "ah"]
There is no reply.
[answering Auto-Doc that "ah" - succeeded]
>
So the rule you're looking for is:
Instead of answering Auto-Doc that "ah":
say "Mmm. Mm-hmm. Very interesting."
After some more research, I have discovered that the responses understood by Inform are yes, no, and sorry. So understand "ah" and "say ah" as saying yes. followed by Instead of saying yes in the presence of the Auto-Doc, say "Mmm. Mm-hmm. Very interesting." is one way to do it.
Here's what the code looks like now:
The exam table is a supporter in the Med Bay. It is fixed in place and enterable.
After entering the exam table, say "A number of LEDs embedded in the ceiling switch on, bathing you in a cold, white light. A panel in the wall opens and an auto-doc trundles forth on a three-wheeled base. Clutching a tongue depressor in its mechanical grip, a small speaker hidden within crackles with the words 'Say, ah.'"
In the Med Bay is a person called Auto-Doc.
Instead of saying yes in the presence of the Auto-Doc, say "Mmm. Mm-hmm. Very interesting."
Understand "ah" and "say ah" as saying yes when location is Med Bay.
Instead of saying no in the presence of the Auto-Doc, say "Hmm..."
This sets up two different non-committal responses for saying yes and no. Saying 'ah' is understood as saying yes, so the player gets a response.

Inform7: Change a room's description depending on where the player came from

I'm pretty new to Inform and it seems like this shouldn't be too hard to do but I haven't yet found a way. I want to change a room's description based on where the player came from. Something along the lines of:
The Town Square is a room. "As you enter the small town square, [if yourself came from West]
the rising sun makes silhouettes of the roofs and spires to the East.[otherwise]your long
shadow strides before you as the Sun rises behind.[end if]"
What's the best way to go about this?
I found a reasonable solution:
The last location is a room that varies.
Orientation is a direction that varies.
Before going to anywhere, now the last location is the location of the player.
After going to anywhere:
now orientation is the best route from the last location to the location, using even locked doors;
continue the action.
The Town Square is a room. "As you enter the small town square, [if orientation is east]
the rising Sun makes silhouettes of the roofs and spires to the East.[otherwise if orientation is west]
your long shadow strides before you as the Sun rises behind.[end if]"
The "using even locked doors" modifier ensures this will work even if a door closes and locks behind the player. The solution does assume that the player has come via a reversible route, which may not always be the case e.g. if the player has teleported.

Computing Checkmate Correctly

When computing checkmate for a king in chess, do you determine the other players possible moves against your king? Or do you consider merely their unit's reach? If you say it's the former, then there is a contradiction like "this statement is false" Consider this image with two kings a square apart and their knights protecting from above rooks. If we assume that the definition of possible moves must prevent check based on enemy possible moves, then the logic recursively alternates.
First, we say that our king is in check from the enemy knight so we are limited from moving our own knight because we must escape.
Then we realize that the knight does not have an available move into our king's square because he will be placing his king in check with our rook. He does not have our king in check after all.
Then we realize, free from check, that we are now able to move our own knight to the enemy king forcing him to move from check and preventing further his choices.
However, we notice that we cannot do this because it will place us in check with the enemy rook.
We realize that since we cannot actually move our knight, the enemy king is not actually in check, therefore he is freely able to use his knight to attack our king.
Go to step 2 (no matter how many times you have already).
Okay, so maybe we assume that reach always counts regardless of the enemy's check status. If our king is in reach of the enemy knight's usual attack range, we consider it a check and must resolve it. Is this how the actual game is ruled though? It seems an easy solution to the problem faced when programming the game logic, but I'm not sure if it is correct or not.
I did some thinking and came up with this analysis:
I think you have proven that the scenario of both kings being in check (not necessarily the scenario of the board I showed) cannot exist by contradiction.
Only one player can make a move at a time.
Therefore, one player makes the initial move which transitions from the state of no kings being in check to some king(s) being in check.
According to the rules, this move is not allowed if that player's king results is in a check. (I will point out the significance of 'results' soon)
This means that no matter how check is defined, he cannot make any move if his king meets that condition.
Therefore, the only transition to checks from no checks is to the enemy being in check.
The enemy must escape check, still following the rule of not entering check in one move.
The remaining state would be game over or that king escaping check.
So I understand that both kings being in check is not possible.
Now the board I showed is either reachable or not reachable.
Let's assume the board is reachable and see if there is a contradiction.
Let's ambiguously assume it's white's turn since the scenario is symmetric.
This means black just moved.
Therefore, black's king is not in check.
The black king is only reachable by the white knight.
Therefore, the white knight must be restricted by some rule to not attack the black king.
The only two possible rules that can enforce that conclusion are:
The white knight is currently protecting his king from check.
The white king is in check already and that move will not solve the check.
First, assume 2 is true regardless of 1.
The white king is in check and the only piece in attack range is black knight.
The black knight cannot attack the square containing king, however, because it would place his own king in check.
Therefore 1 must be true and the white king is not in check.
So both kings are not in check.
We reverse the game board to see if this is reachable.
Assume the scenario with the following alterations:
White has a bishop 2 up and 1 right from the black rook.
The black king is one square to the left.
The white king is one square to the right.
No kings are in range of any other pieces, so it may be reasonable to assume this initial state is reachable.
The black knight is protecting his king from the bishop, so it cannot move to under the white knight.
The white king moves left.
Now the white knight is protecting the white king and cannot move to under the black knight.
The black king moves right one square.
Thus, the scenario is reachable.
The only questioned assumption standing is that when any moves are considered, it is safe to assume that the check rules are computed. Thus, a king may come in range of a unit which may not attack it due to prevention of his own king being in check. If this assumption is not made, then the pieces simply could follow the rules of not allowing kings to enter the unrestricted attack range of an enemy unit.
Now, it is interesting to see if this scenario is computable without infinite loops.
For dependencies, I will use arrows.
For the initial white king moving left,
white king -> black knight stopped -> white bishop attack black king
Those are single step computations, no loops in dependencies so far.
For the black king to move right,
black king -> white knight stopped -> black rook attack white king
Still no dependencies.
What about when we now try to check white knight's available moves including attacking the black king?
white knight stopped -> black rook attack white king
What about if the white rook attacks the black rook?
white rook stopped -> black knight attack white king
White's remaining options are to move the king to the right or down.
Our conclusion,
Moving to this board state is possible without breaking the 'don't move into check' rule.
This board state obviously assumes that computing check depends on possible enemy moves, not their simple native attack ranges.
When this state is reached, both kings are not in check.
It is at least possible that this is not a stalemate. (Unknown if always)
So I finally found rules on wikipedia about placing another king in check even if it compromises one's own king. So, we cannot make our assumption in part 2, thus the board state is not reachable.
"A piece unable to move because it would place its own king in check (it is pinned against its own king) may still deliver check to the opposing player."
Thus our final conclusion for the apparent actual rules of chess, the board state is not reachable as it follows the check rules.
I am going to choose icedtrees answer because of the valuable logic which follows the game rules:
if for every move for player X (ignoring rules about king threats),
player Y can capture player X's king next turn,
then player X is in checkmate.
However, I would fix them to be the following:
{X is checkmate}
if and only if {
For all legal moves:(move according to rule definition) X {
There exists a generic move:(legal move A ignoring rules of protecting king A) Y such that {
X king is captured
}
}
}
I may be misunderstanding, but I think your problem is easily fixed by noting that it is only possible to be in check if it is your own turn. Check in chess is associated strongly with a compulsion to defend the check, and you cannot do that if it is not your turn.
For any chess position, it is VERY IMPORTANT to define whose turn it is, because that lies behind so many mechanics in the game. In your board position, if it is black's turn, then black is in check, and if it is white's turn, then white is in check.
Even if the position is impossible, you can still define some good rules about positions that are good for chess computations.
Some notes on checkmate in chess:
Checkmate is actually not very intuitive, and when you play the game you start to notice funny checkmate situations that do not make much sense.
Here is a good way of thinking about checkmate, in my opinion:
In a legal chess game, when checkmate occurs, the checkmated player is unable to prevent his king being captured the successive turn by the opposing player. That is, checkmate in chess is nothing but "ending the game one turn early", so to speak. If you ignore all rules in chess about threats to the king, but preserve the movement patterns of the pieces, a computer could calculate checkmate by looking forward.
The logic would be as follows:
if for every move for player X (ignoring rules about king threats), player Y can capture player X's king next turn, then player X is in checkmate.
Here is a more complete version of "check and escaping check":
Given it is player X's turn:
if player X's king is in movement range of player Y's piece, it is in check. If the piece cannot escape check, it is checkmate.
There are three ways of escaping check:
Moving your king to a non-attacked square
Blocking the piece(s) delivering check
Capturing the checking piece.
Maybe you're over-thinking this :-)
Here's the algorithm from a working chess program that's relatively strong in human terms:
Generate the list of pseudo-legal moves for the side to move. By pseudo-legal, I mean don't bother to verify whether the generated move leaves that side's King in check. Omitting this verification can save time validating moves that are never searched.
For each move that is searched, validate that it doesn't leave the side to move in check.
If every move leaves the King in check, then the side to move has either been mated or it's stalemate.
If the side to move is currently in check, then it's mate. Otherwise it's stalemate.
My naïve approach would probably go like this.
player.startTurn();
if (player.isInCheck()
if(player.king.hasNoLegalMoves() && player.cannotProtectKing())
game.checkMate(player);
function isInCheck() {
boolean isInCheck = false;
for (Piece p : player.Opponent)
if (p.canAttack(player.king) {
isInCheck = true;
return;
}
I may be missing something here, but I don't understand why it wouldn't be this simple.
For one thing, this board position isn’t even REMOTELY possible.
1) How did you get the rooks and kings off the first and eighth ranks without moving any pawns?
2) Check is defined as the state where your king is under attack by an opposing piece. CheckMATE is the situation where you are in check and cannot legally get out of check.
3) If it’s your turn and one of your pieces is capable of capturing the opponent’s king, it doesn’t matter if you would put yourself in check to do so: it’s whose king would die first?
4) Notwithstanding that, if it’s your turn and your opponent is in check, it either means neither player noticed that your opponent was in check (in which case you go back and make sure they can—and do—get out of check before you do anything else) or that nobody noticed that it was checkmate.
So, when it’s your turn you can’t finish in check, but when determining a threat to the king, the opposing king’s safety is irrelevant.

epub 2-column page break and layout

I am creating a 2-column epub book for a specific device. My problem is that when I use css to specify the columns ( -webkit-column-count: 2; -webkit-column-rule: 0px;), the end result is:
on Page 1 it shows (Part 1 | Part 3), and
on Page 2 it shows (Part 2 | Part 4) of the poem.
I would prefer to do it in a more natural book flow, which should show
(Part 1 | Part 2) on page 1, and continue to
(Part 3 | Part 4) on page 2.
Is there a way to archive this?
Some additional notes:
I tried to limit the column height but all it does is to add a 3rd column, which is not what I want.
The content of the book is dynamically generated, and thus, I cannot specify the location of the break ahead of time.
What are you applying the column count to?
http://jsfiddle.net/carolrmckay/FECr9/4/
.columncount
{
-webkit-column-count: 2; -webkit-column-rule: 0px;
}
strong
{
font-weight:bold;
}
<ul>
<li class="columncount"><p><strong>Chapter</strong> 1 – Down the Rabbit Hole: Alice is feeling bored while sitting on the riverbank with her sister, when she notices a talking, clothed White Rabbit with a pocket watch run past. She follows it down a rabbit hole when suddenly she falls a long way to a curious hall with many locked doors of all sizes. She finds a small key to a door too small for her to fit through, but through it she sees an attractive garden. She then discovers a bottle on a table labelled "DRINK ME", the contents of which cause her to shrink too small to reach the key which she has left on the table. A cake with "EAT ME" on it causes her to grow to such a tremendous size her head hits the ceiling.</p>
<p><strong>Chapter</strong> 2 – The Pool of Tears: Alice is unhappy and cries as her tears flood the hallway. After shrinking down again due to a fan she had picked up, Alice swims through her own tears and meets a Mouse, who is swimming as well. She tries to make small talk with him in elementary French (thinking he may be a French mouse) but her opening gambit "Où est ma chatte?" (that is "Where is my cat?") offends the mouse.
</p>
<p><strong>Chapter</strong> 3 – The Caucus Race and a Long Tale: The sea of tears becomes crowded with other animals and birds that have been swept away by the rising waters. Alice and the other animals convene on the bank and the question among them is how to get dry again. The mouse gives them a very dry lecture on William the Conqueror. A Dodo decides that the best thing to dry them off would be a Caucus-Race, which consists of everyone running in a circle with no clear winner. Alice eventually frightens all the animals away, unwittingly, by talking about her (moderately ferocious) cat.
</p>
<p><strong>Chapter</strong> 4 – The Rabbit Sends a Little Bill: The White Rabbit appears again in search of the Duchess's gloves and fan. Mistaking her for his maidservant, Mary Ann, he orders Alice to go into the house and retrieve them, but once she gets inside she starts growing. The horrified Rabbit orders his gardener, Bill the Lizard, to climb on the roof and go down the chimney. Outside, Alice hears the voices of animals that have gathered to gawk at her giant arm. The crowd hurls pebbles at her, which turn into little cakes. Alice eats them, and they reduce her again in size.
</p>
<p><strong>Chapter</strong> 5 – Advice from a Caterpillar: Alice comes upon a mushroom and sitting on it is a blue Caterpillar smoking a hookah. The Caterpillar questions Alice and she admits to her current identity crisis, compounded by her inability to remember a poem. Before crawling away, the caterpillar tells Alice that one side of the mushroom will make her taller and the other side will make her shorter. She breaks off two pieces from the mushroom. One side makes her shrink smaller than ever, while another causes her neck to grow high into the trees, where a pigeon mistakes her for a serpent. With some effort, Alice brings herself back to her usual height. She stumbles upon a small estate and uses the mushroom to reach a more appropriate height.
The Cheshire Cat
</p>
<p><strong>Chapter</strong> 6 – Pig and Pepper: A Fish-Footman has an invitation for the Duchess of the house, which he delivers to a Frog-Footman. Alice observes this transaction and, after a perplexing conversation with the frog, lets herself into the house. The Duchess's Cook is throwing dishes and making a soup that has too much pepper, which causes Alice, the Duchess, and her baby (but not the cook or grinning Cheshire Cat) to sneeze violently. Alice is given the baby by the Duchess and to her surprise, the baby turns into a pig. The Cheshire Cat appears in a tree, directing her to the March Hare's house. He disappears but his grin remains behind to float on its own in the air prompting Alice to remark that she has often seen a cat without a grin but never a grin without a cat.
</p>
<p><strong>Chapter</strong> 7 – A Mad Tea-Party: Alice becomes a guest at a "mad" tea party along with the March Hare, the Hatter, and a very tired Dormouse who falls asleep frequently, only to be violently woken up moments later by the March Hare and the Hatter. The characters give Alice many riddles and stories, including the famous 'Why is a raven like a writing desk?'. The Hatter reveals that they have tea all day because Time has punished him by eternally standing still at 6 pm (tea time). Alice becomes insulted and tired of being bombarded with riddles and she leaves claiming that it was the stupidest tea party that she had ever been to.
Alice trying to play croquet with a Flamingo.
</p>
<p><strong>Chapter</strong> 8 – The Queen's Croquet Ground: Alice leaves the tea party and enters the garden where she comes upon three living playing cards painting the white roses on a rose tree red because the Queen of Hearts hates white roses. A procession of more cards, kings and queens and even the White Rabbit enters the garden. Alice then meets the King and Queen. The Queen, a figure difficult to please, introduces her trademark phrase "Off with his head!" which she utters at the slightest dissatisfaction with a subject. Alice is invited (or some might say ordered) to play a game of croquet with the Queen and the rest of her subjects but the game quickly descends into chaos. Live flamingos are used as mallets and hedgehogs as balls and Alice once again meets the Cheshire Cat. The Queen of Hearts then orders the Cat to be beheaded, only to have her executioner complain that this is impossible since the head is all that can be seen of him. Because the cat belongs to the Duchess, the Queen is prompted to release the Duchess from prison to resolve the matter.
</p>
<p><strong>Chapter</strong> 9 – The Mock Turtle's Story: The Duchess is brought to the croquet ground at Alice's request. She ruminates on finding morals in everything around her. The Queen of Hearts dismisses her on the threat of execution and she introduces Alice to the Gryphon, who takes her to the Mock Turtle. The Mock Turtle is very sad, even though he has no sorrow. He tries to tell his story about how he used to be a real turtle in school, which the Gryphon interrupts so they can play a game.
</p>
<p><strong>Chapter</strong> 10 – Lobster Quadrille: The Mock Turtle and the Gryphon dance to the Lobster Quadrille, while Alice recites (rather incorrectly) "'Tis the Voice of the Lobster". The Mock Turtle sings them "Beautiful Soup" during which the Gryphon drags Alice away for an impending trial.
</p>
<p><strong>Chapter</strong> 11 – Who Stole the Tarts?: Alice attends a trial whereby the Knave of Hearts is accused of stealing the Queen's tarts. The jury is composed of various animals, including Bill the Lizard, the White Rabbit is the court's trumpeter, and the judge is the King of Hearts. During the proceedings, Alice finds that she is steadily growing larger. The dormouse scolds Alice and tells her she has no right to grow at such a rapid pace and take up all the air. Alice scoffs and calls the dormouse's accusation ridiculous because everyone grows and she can't help it. Meanwhile, witnesses at the trial include the Hatter, who displeases and frustrates the King through his indirect answers to the questioning, and the Duchess's cook.
</p>
<p><strong>Chapter</strong> 12 – Alice's Evidence: Alice is then called up as a witness. She accidentally knocks over the jury box with the animals inside them and the King orders the animals be placed back into their seats before the trial continues. The King and Queen order Alice to be gone, citing Rule 42 ("All persons more than a mile high to leave the court"), but Alice disputes their judgement and refuses to leave. She argues with the King and Queen of Hearts over the ridiculous proceedings, eventually refusing to hold her tongue. The Queen shouts her familiar "Off with her head!" but Alice is unafraid, calling them out as just a pack of cards; just as they start to swarm over her. Alice's sister wakes her up for tea, brushing what turns out to be some leaves and not a shower of playing cards from Alice's face. Alice leaves her sister on the bank to imagine all the curious happenings for herself.</li>
</ul>​

How do I make both "inside" and "south" go through a door in Inform 7?

Suppose we have:
The storm door is a closed door. It is south of the Garden and north of the Shed.
The following commands all work fine to go through the door from the Garden:
south
s
go through storm door
go through
enter door
However go in doesn't work:
>go in
You can't go that way.
and I can't find a reasonable way to make it work. The best I can do is this, which seems rather absurd:
Inside of the garden is Tumbolia. Outside of the shed is Tumbolia.
Instead of going to Tumbolia from the garden, try entering the storm door.
Instead of going to Tumbolia from the shed, try entering the storm door.
I think you could also do this:
The storm door is a closed door. It is south of the Garden and north of the Shed.
The Shed is inside from the Garden.
Instead of going inside from the Garden, try going south.
Instead of going outside from the Shed, try going north.
The best I was able to come up with was:
Instead of going nowhere in the Garden when the noun is inside, try entering the storm door.
Instead of exiting in the Shed, try entering the storm door.
With this wording, go in / go inside / in / inside all work when in the Garden, and go out / go outside / out / outside / leave / exit all work when in the Shed.
The asymmetry here is because out and go out are interpreted as exiting, a special action. (It is converted to going outside by “the convert exit into go out rule”, but only if there is actually a door or room in the “outside” direction.) Whereas in and go in are interpreted as going inside from the beginning; there is no handy generic entering action for us to use.
To make just plain enter work, add:
Rule for supplying a missing noun when entering in the Garden: now the noun is the storm door.

Resources