Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Text based games parser.

Author
Message
Dextro
19
Years of Service
User Offline
Joined: 26th Feb 2005
Location:
Posted: 23rd May 2007 06:30
Hello.
I didn't know in which forum this question belong, so I'll try my luck here.
Where can find tutorials on making parsers for text based games?
I did some surfing on the net, but I couldn't find anything of relevance.
I'd like the tutorials to be for DB or c#.
Thanks.
Hobgoblin Lord
19
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 23rd May 2007 15:38
Check the game design theory board for last years text adventure competition, I posted some code to show how to make and use a parser for those who were unaware. It was a simple 2 word verb/noun parser.

Dazzag
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Cyprus
Posted: 23rd May 2007 15:50
C'mon then Dextro, what is your text adventure going to be about? It's been a bit quiet about the adventure game competition. Seriously like this stuff.

Cheers

I am 99% probably lying in bed right now... so don't blame me for crappy typing
Current fave quote : "She was like a candle in the wind.... unreliable...."
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 23rd May 2007 16:16 Edited at: 23rd May 2007 16:27
Dextro, your best bet is to browse around for vintage/retro programming books. I have one "Programming Your Own Text Adventures" which has source code in Basic for Commodore/Atari/AppleII etc... It doesn't take much to convert the principles to todays languages, although some of that spaghetti code (goto linenumber) and 1-2 letter variable names can scramble anyone's brain.

I am currently going through my retro computer archives to locate my book. I have a picture of it (it's the spiral bound tan book at the top, next to FASSM and Adventure Creator). Once I find the actual title ISBN I'll give you a link to a digital version.



What's really interesting is the book covers about 30 of the most popular text adventures at the time, reviewing what new ideas and game mechanics were used, and why they were loved/hated too simple too difficult. So you can get a full understanding of the progression. The first half of the book is sorted by developer. The second half goes into coding the games yourself, including parsing and tokenizing the english language. It ends off with a simple adventure/parser called Clock Tower!

Dazzag
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Cyprus
Posted: 23rd May 2007 16:34
Quote: "although some of that spaghetti code (goto linenumber) and 1-2 letter variable names can scramble anyone's brain"
Ummm. Yeah. So long ago (you really wouldn't want to see the main system we use at work).....

Quote: "The second half goes into coding the games yourself, including parsing and tokenizing the english language"
Cool. I think I had something similar. Managed to lose it though annoyingly. I also seem to recognise most of the books in the picture.... My favourite though was that speccy adventure creator PAW which came in a box that looked like a book. Nice.

Cheers

I am 99% probably lying in bed right now... so don't blame me for crappy typing
Current fave quote : "She was like a candle in the wind.... unreliable...."
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 23rd May 2007 17:55 Edited at: 23rd May 2007 17:59
Eureka!! I found my book. I'll try to see if there is an on-line version as the book is long out of print!

If not, I'll see about paraphrasing the How They Work Section too get people started, which includes:



Of course it was hidden in my Compute! Collection.

Here's the specifics...

Title: "COMPUTE!'s Guide to Adventure Games"
Author: Gary McGath
Copyright 1984
ISBN 0-942386-67-1

Table Of Contents
1. Stories in Software
2. What Makes a Good Adventure?
3. Infocom Adventures
-Zork I
-Zork II
-Zork III
-Deadline
-Starcross
-Suspended
-Witness
-Planetfall
-Enchanter
-Sorcerer
-Infidel

4. Scott Adams Adventures
-Adventureland
-Pirate's Adventure
-Adventure #3
-Vodoo Castle
-The Count
-Strange Odyssey
-Mystery Fun House
-Pyramid of Doom
-Ghost Town
-Savage Island
-Golden Voyage

5. Sierra On-Line Adventures
-Mystery House
-The Wizard and the Princess
-Cranston Manor
-Ulysses and the Golden Fleece
-Time Zone
-Dark Crystal

6. More Adventures
-Adventure
-Asylum
-Asylum II
-Bedlam
-Blade of Blackpoole
-Cyborg
-Dungeon
-Empire of the Over-Mind
-G.F.S. Sorceress
-Haunted House
-Lords of Karma
-Merlin's Treasure
-Prisoner 2
-Pyramid
-Raaka-Tu
-The Sledge of Rahmul
-Spook House
-Stone of Sisyphus
-Toxic Dumpsite
-Xenos

7. Action Adventures
8. A Field Guide for Frustrated Adventurers
9. How they work
10. Doing your own
11. Tower of Mystery: A simple Adventure Program
12. The Edge of the Future (this is ammusing to read today!)
Suggested Reading
Index

Dextro
19
Years of Service
User Offline
Joined: 26th Feb 2005
Location:
Posted: 23rd May 2007 18:00 Edited at: 23rd May 2007 18:15
I appreciate all your help.
I'll try to find the book you mention zen, it sounds very promising.
Thank you.
edit:
I found the "How they work" part, I think that'll do it.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 23rd May 2007 18:24
Sounds like the kinda thing I would genuinelly find "fun" to figure out myself, but that's from my experience in making tokenizers and parsers for programming languages.

Vampiric
18
Years of Service
User Offline
Joined: 30th Oct 2006
Location:
Posted: 23rd May 2007 18:32 Edited at: 23rd May 2007 18:36
Here's snippets from the book before you buy it

http://www.mud.co.uk/richard/cgtaghtw.htm

Chapters I found from the book:

Chapter 1 - http://www.malinche.net/interactivefictionstoriesinsoftware.html

Chapter 2 -http://www.malinche.net/howtextadventuregameswork.html

Link from Amazon with resellers - http://www.amazon.co.uk/gp/offer-listing/0942386671/ref=dp_olp_2/202-6403709-9581458?ie=UTF8&qid=1179934527&sr=11-1

Hope that was some help.

Computer says n00bed
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 23rd May 2007 18:54
Thanks Vampiric that's the book! It actually helped me alot back in 1985, and honestly as I read it today, it still offers a wealth of information. The sample adventure isn't the greatest, but It's enough to get anyone started in the right direction. Honestly, I enjoyed reading about a lot of the games I had played, and some that I had missed

@zotoaster, I agree with you on coding your own. But If you've never written a Parser/tokenizer before, and if you never had much experience with text adventures, it may be a foreign concept.

The source in this book, covers the basics and the information guides you into developing further. English can be a difficult language to parse. Many of us don't remember or know proper grammar; especially if we've been out of school for a number of years. Actually, at least in the U.S., I think we have a better understanding of grammar in Elementary/grade School.

I haven't thought about the following since 3-5th grade

I. Parts of a sentence
a. subject/predicate
b. imperative sentence

II.The Predicate (parts):
a. verb
b. direct object
c. indirect object

III. The Prepositional Phrase and Relationships

IV. Dealing with multiple objects (direct,indirect,prepositions)

So I think the book, although straight foward is a good refresher!

zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 23rd May 2007 19:36
I think I will translate the example game's source to DBpro. It may just give people who would like to enter the "Text Adventure Competition" a platform to build on. Especially New-Comers and anyone else who is either not familiar with the genre, or the basic fundamental's behind the coding of one.

It shouldn't take me too long, but I can foresee a few translations before I get it right. The reason being that the older basic, just gets real ugly real fast, and the code is completely obfuscated, even with remarks. Tons of gotos and error trappings, pure Spaghetti.

The source becuase of naming limitations also uses obscure variable and array names. A lot are one or two letters. So picking it apart can be a headache.

I'll probably do one very-near-to-generic-basic translation to get the code in a more manageable state. Then I'll translate that code to DBpro's Funtction/UDT capabilities.

Dazzag
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Cyprus
Posted: 23rd May 2007 19:46
Nice one Zenassem. That will probably cause a fair few people to perhaps reconsider entering the competition.

Cheers

I am 99% probably lying in bed right now... so don't blame me for crappy typing
Current fave quote : "She was like a candle in the wind.... unreliable...."
Dextro
19
Years of Service
User Offline
Joined: 26th Feb 2005
Location:
Posted: 23rd May 2007 19:58
Thanks a lot for the help Vampiric, I just ordered a copy for myself.
Zen, it would be great if you could make some kind of tutorial on the matter, I'm positive many of us would be very excited about the idea.
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 23rd May 2007 20:05
Thanks Dazzag!

I can't believe the price those resellers are charging. I purchased it in 1985 for $12.95. Guess they are counting on the collector, and figuring in inflation.

I Never knew my collection was worth even a penny. I have nearly every book that came out on programming for the commodore64 & Atari. I have close to every Compute! book published (at least the good volumes), and most of the magazines issues (except for Compute! Gazette) which I didn't subscribe to.

I figured all of them were elctronically archived and freely distributable by now.

zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 23rd May 2007 20:06
@Dextro, I'll have a simple translation of the Tower game, by evening tonight with commenting, and updated structure.

Then tomorrow, I'll enhance it a bit, and compile my own explanation coupled with the book.

Dazzag
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Cyprus
Posted: 24th May 2007 10:54 Edited at: 24th May 2007 10:55
Compute! I remember that one. Wasn't another called Input or somesuch? I remember being on my spectrum typing away pages of code from the magazine (literally like 5 full pages of really small typed code) while my dad or friend spoke the lines out. Not so bad for most of the programs, but when you got half a dozen pages of data statements... oh God.....

It went something like this:-
100 DATA 1,0,1,0,0,1,0,1,0,0,0,0,0,0,1,1,1,1,1,1,0
110 DATA 1,0,1,0,0,1,0,1,0,0,1,0,0,1,1,0,1,0,1,1,0
120 DATA 0,0,1,0,0,1,0,1,0,1,1,1,1,0,1,1,1,1,1,1,0
..etc...

And how did you debug it when something went wrong? For me and everyone I knew if we couldn't work it out (another day or two scanning the pages and the inputted code, only to find a month later where they post a fix to a line that was causing the problems) then we just kept deleting the offending lines until something resembling the game actually worked I didn't bother after a while and just wrote my own stuff.

Cheers

I am 99% probably lying in bed right now... so don't blame me for crappy typing
Current fave quote : "She was like a candle in the wind.... unreliable...."
Hobgoblin Lord
19
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 24th May 2007 17:25
Compute and Byte were the two I got. Typing those in were a pain, but it is how I learned to program in the beginning, with a "what happens if I change this?" method of learning.

Dazzag
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Cyprus
Posted: 24th May 2007 18:07
Quote: "but it is how I learned to program in the beginning"
My dad got me the speccy for Xmas and then gave me the manuals. He said if I read the books from cover to cover then I could play the games that he had bought (Horace and the spiders and Harrier Attack I believe). One of the books was basically a manual for BASIC. ie. very big. After 2 days of going through like 1/2 the book my dad let me play the games, but not till I had realised programming was far more enjoyable to me than playing the actual games (they were pretty good though).

For some reason the mags just made me type in the code to see if I could get a free game (remember the radio show that would broadcast a game to download???).

Heh, although I do remember that an example in the mags (something like for n=1 to 12..... etc.... next n) made me think "for n" and "next n" was the actual command for ages (they always used "n"), and "for s" and "next s" was for subloops Even now "for n" feels more right than anything else (and "for s" for subloops). Think it was the way they explained it in the tutorial.

Cheers

I am 99% probably lying in bed right now... so don't blame me for crappy typing
Current fave quote : "She was like a candle in the wind.... unreliable...."
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 24th May 2007 21:54 Edited at: 24th May 2007 21:55
Quote: "And how did you debug it when something went wrong? "


I forget what issue it was, but it was truly a blessing when Compute! introduced a line checker, as simple extension to basic via a machine language subroutine (sort of a checksum). From that point on, you could type the line and it would give you a number after you pressed return. I would check that # against the source code's checksum #.

I typed all the programs in as well. Even though I started getting them on diskette. It was a great learning process, except the parts like you mention, where you two pages of data statements that are being poked to the screen memory, or somewhere else.

I had a memory map, for both Atari & commodore 64, of all the interesting peeks and pokes.

Dextro
19
Years of Service
User Offline
Joined: 26th Feb 2005
Location:
Posted: 24th May 2007 22:08 Edited at: 24th May 2007 22:08
I managed to make a simple function in c# that will format a string, and extract individual words from it, now i just need to know what would be best, store the words in an array ("commands[20]"), or what?
Also, what would be the best approach to store the keywords (verbs and nouns) with their synonyms? In a multidimensional array?
I mention arrays so much since I'm kinda new to c#, I'm not having difficulty learning it, in fact I managed to make a very simple tile engine with the xna framework, but I'm not using any literature, so I'm kind of limited on my knowledge of what is avaiable besides arrays.
Some help here would be great.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 24th May 2007 22:13
I would store them in a linked list, unless you already know how many words there are.

I suggest you guys take a look at regular expressions (or regexp) if noone's already mentioned them. They are very useful for parsing. http://en.wikipedia.org/wiki/Regular_expression

zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 24th May 2007 22:14
You are on the right track Dextro. I would do exactly what you suggest. Multidimensional array.

It's not as important these days, but I used to limit the length of my commands to five characters. Anything after is the same word. This seemed to also help people with mispelling. And it allows people to short-type words. If you do something like that, you just have to make sure that two different commands don't share the same letters up to your limit.

zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 24th May 2007 22:27
BTW, I didn't have much coding time yesterday, but I began translating the code.

I'll hopefully finish this afternoon. The problem is like I stated earlier. The source code is spaghetti.

-The main-loop (if you can even call it that) jumps all over the place, multiple times, for multiple if conditions
-goto's all over the place; which I need to eliminate and make more procedural. I could just follow it to the "T" but I can't bring myself to do that.
-Even using goto's to jump out of a for loop early.
-On c1 1000,1010,1050 etc... commands; which are like archaic case statements.
-Heavy use of 3 parameter Mid$; so I'll either use someone elses or code my own real quick.
-Print statements here there and everywhere, without having to deal with a common sync.
-I'll probably leave the first version as is, with numerous single dimension arrays, but It really could be handled better with less multi-dimensional arrays.
-Tons of flags that redirect code flow, more spaghetti to unloop.

Login to post a reply

Server time is: 2024-11-18 17:29:24
Your offset time is: 2024-11-18 17:29:24