How do I fix this problem?

This is a discussion / support forum for the Hugo programming language by Kent Tessman. Hugo is a powerful programming language for making text games / interactive fiction with multimedia support.

Hugo download links: https://www.generalcoffee.com/hugo
Roody Yogurt's Hugo Blog: https://notdeadhugo.blogspot.com
The Hugor interpreter by RealNC: http://ifwiki.org/index.php/Hugor

Moderators: Ice Cream Jonsey, joltcountry

User avatar
Tdarcos
Posts: 9333
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

How do I fix this problem?

Post by Tdarcos »

I've started writing a new interactive fiction game and have found an interesting peccadillo in Hugo (or else I'm not doing this right).

In this example, transport is a declared attribute.
Take the following grammar:

Code: Select all

verb "climb"
 * transport			DoClimbTrans
 * "up" transport		DoClimbUpTrans
 * "down" transport	        DoClimbDownTrans
 * "on" transport		DoClimbOnTrans
 * "on" "board" transport	DoBoardTrans
 * "off" transport		DoClimbOffTrans
 * "off" "of" transport		DoClimbOffTrans
There is an object in the game with the noun steps which has is transport. So the commands
>climb stairs
>climb on stairs
do work, but
>climb up stairs
>climb down stairs
get the error message beginning with "You haven't encountered anything like that." A global search on "haven't encountered anything" produces no hits. So I'm figuring this is a message from the game engine. However, if I edit the above to:

Code: Select all

verb "climb"
 * transport			DoClimbTrans
 * "xx" transport		DoClimbUpTrans
 * "xxxx" transport	        DoClimbDownTrans
 * "on" transport		DoClimbOnTrans
 * "on" "board" transport	DoBoardTrans
 * "off" transport		DoClimbOffTrans
 * "off" "of" transport		DoClimbOffTrans
then the commands
>climb xx stairs
>limb xxxx stairs
work correctly.

Is it that the system does not like intermediate words that match other verbs? In writing this i can probably "get around" this by substituting the attribute direction for "up" or "down" and filter it either in DoClimbUp or in the object's before routine to check for the direction being up or down. (And it's probably a good idea to change the name of the routine.)
Alan Francis wrote a book containing everything men understand about women. It consisted of 100 blank pages.

User avatar
Jizaboz
Posts: 4811
Joined: Tue Jan 31, 2012 2:00 pm
Location: USA
Contact:

Re: How do I fix this problem?

Post by Jizaboz »

Are you sure your stairs or whatever are in scope? Ie; the error message you are getting tells me the object you are trying to interact with is not in the same “room”
(╯°□°)╯︵ ┻━┻

User avatar
Tdarcos
Posts: 9333
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

Re: How do I fix this problem?

Post by Tdarcos »

Jizaboz wrote: Mon Nov 11, 2019 1:03 am Are you sure your stairs or whatever are in scope? Ie; the error message you are getting tells me the object you are trying to interact with is not in the same “room”
As I said, typing "climb on stairs' works and if I change "up" to "xx" in the grammar, "climb xx stairs" works.

With a little bit of work i discovered that because of u_obj having the noun of up, it turns up into an object. So typing "up stairs' it sees that as two objects together, with no separating words, which breaks the rules. Or I think so, if I have object xobject in grammar, t I can see what that does.
Alan Francis wrote a book containing everything men understand about women. It consisted of 100 blank pages.

User avatar
Ice Cream Jonsey
Posts: 28879
Joined: Sat Apr 27, 2002 2:44 pm
Location: Colorado
Contact:

Re: How do I fix this problem?

Post by Ice Cream Jonsey »

I think what it is going on is that it knows what the word "up" and "down" are but thinks they are directions. You are using them as adjectives. Can you add those words as adjectives to your stairs object and see what happens?
the dark and gritty...Ice Cream Jonsey!

User avatar
Flack
Posts: 8822
Joined: Tue Nov 18, 2008 3:02 pm
Location: Oklahoma
Contact:

Re: How do I fix this problem?

Post by Flack »

Tdarcos wrote: Mon Nov 11, 2019 12:30 am

Code: Select all

verb "climb"
 * transport			DoClimbTrans
 * "up" transport		DoClimbUpTrans
 * "down" transport	        DoClimbDownTrans
 * "on" transport		DoClimbOnTrans
 * "on" "board" transport	DoBoardTrans
 * "off" transport		DoClimbOffTrans
 * "off" "of" transport		DoClimbOffTrans
People playing interactive fiction games understand that stairs go up and down, and will simply type "up" to go up and "down" to go down. You're trying to solve a problem that doesn't exist.
"I failed a savings throw and now I am back."

User avatar
Tdarcos
Posts: 9333
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

Re: How do I fix this problem?

Post by Tdarcos »

Ice Cream Jonsey wrote: Mon Nov 11, 2019 11:28 am … knows what… "up" and "down" are… You are using them as adjectives. Can you add those words as adjectives to your stairs object and see what happens?
Which "up" do you want, 1) above 2) steps?

Yeah, tried that.
Alan Francis wrote a book containing everything men understand about women. It consisted of 100 blank pages.

Roody_Yogurt
Posts: 2179
Joined: Mon Apr 29, 2002 6:23 pm
Location: Milwaukee

Re: How do I fix this problem?

Post by Roody_Yogurt »

If you read the section on grammar in the Hugo manual, grammar has to be declared in a certain order to work properly.

Code: Select all

verb "climb"
 * "up" transport		DoClimbUpTrans
 * "down" transport	        DoClimbDownTrans
 * "on" "board" transport	DoBoardTrans
 * "on" transport		DoClimbOnTrans
 * "off" transport		DoClimbOffTrans
 ! * "off" "of" transport		DoClimbOffTrans
 * transport			DoClimbTrans
(The line with "of" in it isn't even needed since Hugo automatically removes it from commands.)

As you can see, the simplest version of the command should always be listed last with ones with extra words declared first. I only tested the commands you said didn't work, and they worked fine for me.

User avatar
bryanb
Posts: 807
Joined: Sat Apr 06, 2019 2:56 pm

Re: How do I fix this problem?

Post by bryanb »

Flack wrote: Mon Nov 11, 2019 1:23 pm People playing interactive fiction games understand that stairs go up and down, and will simply type "up" to go up and "down" to go down.
Well, some will. In reality, it's hard to predict what users are going to type in a given situation. I think you have to assume they're crazy and utterly nonstandard until proven otherwise. Even the same user won't always type the same thing in every game or in every situation. I think I would usually use "up" and "down" in a stairs situation as you suggested, but I definitely will sometimes use "climb up stairs" or "climb up" as well. The best parsers are the most accommodative, period.

Post Reply