Interactive Fiction Parser

Creating Games? Developing something for fun?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
hypercardjdowns
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 15
Joined: Sat Mar 02, 2019 2:04 pm
Location: Missouri, USA

Interactive Fiction Parser

Post by hypercardjdowns » Sat Aug 31, 2019 5:59 pm

I've decided to create an interactive fiction game using LiveCode. Does anyone know if someone has already created code to parse user input that I could review for adaptation?
Last edited by hypercardjdowns on Sat Aug 31, 2019 7:36 pm, edited 1 time in total.
D. John Downs | Old school HyperCard enthusiast | Novice LC Indy hobbyist
I have an extremely busy career, so please forgive my "come and go" manner.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7046
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Interactive Fiction Parser

Post by FourthWorld » Sat Aug 31, 2019 6:49 pm

I've been thinking about converting any of the popular libraries used for chat interfaces to LC, given the time to pursue it (read, "not likely soon" <g>).

But for interactive fiction, do you really want the user to have to type into an open field, or would multiple choice provide a better experience?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

hypercardjdowns
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 15
Joined: Sat Mar 02, 2019 2:04 pm
Location: Missouri, USA

Re: Interactive Fiction Parser

Post by hypercardjdowns » Sat Aug 31, 2019 7:09 pm

Thanks, Richard.

I've been debating this internally for quite a little while now. The trend in much recent interactive fiction is to provide a limited number of choices (a la Choose Your Own Adventure). I'm very torn about this, however. I'm quite old, so far as technology goes. My roots hearken to the likes of Adventure and Infocom. I see much of the new model as "gaming on rails." My heart pushes me toward a more open model.

I'm not talking a parser like Infocom's monster. Something simpler. I've been roughing out what I think (hope) would be a workable framework:

1. Receive input from user
2. Strip all punctuation from input (is this necessary in modern X-Talk?)
3. Strip articles, prepositions, and other unnecessary words
4. Replace synonym verbs with standard verbs (eg, EXAMINE to LOOK)
5. Strip overused verbs to make noun the focus in special cases (eg, LOOK, GO)
6. Ensure verb is the first word in the remaining word cluster
7. Compare remaining word cluster with available verb word clusters (66% match threshold?)
8. Assign an actionable “command” based on the closest matching word cluster
9. Use code to assess the command and take action within the game's current context

This really would be a passion project, something to do for fun as I head toward retirement in a few years.
D. John Downs | Old school HyperCard enthusiast | Novice LC Indy hobbyist
I have an extremely busy career, so please forgive my "come and go" manner.

bogs
Posts: 4006
Joined: Sat Feb 25, 2017 10:45 pm

Re: Interactive Fiction Parser

Post by bogs » Sat Aug 31, 2019 10:25 pm

I remember playing some of those on the IIe one of my friends had. From what I remember, they weren't quite as interactive as you might imagine. Although it is true you could type anything in, like "hang my self in the corner", usually if it didn't fit the several patterned responses you got the 'catch-all' response, something to the effect of "You can not hang yourself in the corner".

This was basically the set of 2 strings, concatenated with parts of your string, i.e.
"You can not" && yourText

Ah, the illusion of freedom!
Image


hypercardjdowns
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 15
Joined: Sat Mar 02, 2019 2:04 pm
Location: Missouri, USA

Re: Interactive Fiction Parser

Post by hypercardjdowns » Fri Sep 06, 2019 1:59 am

mwieder wrote:
Fri Sep 06, 2019 1:05 am
You might be interested in...
Thank you.
D. John Downs | Old school HyperCard enthusiast | Novice LC Indy hobbyist
I have an extremely busy career, so please forgive my "come and go" manner.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2847
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Interactive Fiction Parser

Post by mwieder » Fri Sep 06, 2019 2:06 am

The LISP-inspired source for the Zork parser is also now on github.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7046
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Interactive Fiction Parser

Post by FourthWorld » Fri Sep 06, 2019 3:05 am

bogs wrote:
Sat Aug 31, 2019 10:25 pm
I remember playing some of those on the IIe one of my friends had. From what I remember, they weren't quite as interactive as you might imagine. Although it is true you could type anything in, like "hang my self in the corner", usually if it didn't fit the several patterned responses you got the 'catch-all' response, something to the effect of "You can not hang yourself in the corner".

This was basically the set of 2 strings, concatenated with parts of your string, i.e.
"You can not" && yourText

Ah, the illusion of freedom!
There used to be a game developer meetup here in LA back in the day, and we once had Chris Crawford as our speaker. If you know his career, he's made a lot of both open input and multiple choice games.

He referred to open input as ultimately being a sort is metagame, which he called "Hunt the Parser", where it's really easy for the user to spend a lot of time away from the game's story just to poke around to see what the input parser would tolerate.

That said, the industry has come a long way since then. In those days interactive fiction was one of the few relevant domains for such parsers.

Today we have a renewed interest in this for other applications, mostly chat-driven automation.

So even while a multiple choice setup might be a better user experience, and would certainly be easier to program, the time spent exploring parsers may pay off in the long run in unexpected ways.

Who knows? Maybe before you're done you'll have a good parser and hook it into LiveCode Server and host chat-driven services.

More work, but if it has your attention this seems a good time to capitalize on that motivation to learn as much as you can about it.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

hypercardjdowns
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 15
Joined: Sat Mar 02, 2019 2:04 pm
Location: Missouri, USA

Re: Interactive Fiction Parser

Post by hypercardjdowns » Fri Sep 06, 2019 3:08 am

FourthWorld wrote:
Fri Sep 06, 2019 3:05 am
More work, but if it has your attention this seems a good time to capitalize on that motivation to learn as much as you can about it.
Agreed. It's actually just as much about keeping me occupied as it is creating a game. 8)
D. John Downs | Old school HyperCard enthusiast | Novice LC Indy hobbyist
I have an extremely busy career, so please forgive my "come and go" manner.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2847
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Interactive Fiction Parser

Post by mwieder » Fri Sep 06, 2019 4:46 am

LOL. I know that feeling well.

Galeb_G4
Posts: 2
Joined: Thu Sep 26, 2019 6:29 pm

Re: Interactive Fiction Parser

Post by Galeb_G4 » Thu Sep 26, 2019 6:54 pm

hypercardjdowns wrote:
Sat Aug 31, 2019 7:09 pm
Thanks, Richard.

I've been debating this internally for quite a little while now. The trend in much recent interactive fiction is to provide a limited number of choices (a la Choose Your Own Adventure). I'm very torn about this, however. I'm quite old, so far as technology goes. My roots hearken to the likes of Adventure and Infocom. I see much of the new model as "gaming on rails." My heart pushes me toward a more open model.

I'm not talking a parser like Infocom's monster. Something simpler. I've been roughing out what I think (hope) would be a workable framework:

1. Receive input from user
2. Strip all punctuation from input (is this necessary in modern X-Talk?)
3. Strip articles, prepositions, and other unnecessary words
4. Replace synonym verbs with standard verbs (eg, EXAMINE to LOOK)
5. Strip overused verbs to make noun the focus in special cases (eg, LOOK, GO)
6. Ensure verb is the first word in the remaining word cluster
7. Compare remaining word cluster with available verb word clusters (66% match threshold?)
8. Assign an actionable “command” based on the closest matching word cluster
9. Use code to assess the command and take action within the game's current context

This really would be a passion project, something to do for fun as I head toward retirement in a few years.
This really sounds great, I'll make sure to check if you do end up writing something like that! But it sounds quite complicated, you sound experienced and it could be something you could do, but for us beginners, going for a more "rail-based" interactive adventure (something between the "choose your own adventure" and "visual novel" genres) could be a much easier thing to write.

Post Reply

Return to “Creating Games”