Lazarus

Free Pascal => Beginners => Topic started by: Wysardry on June 07, 2019, 09:03:48 pm

Title: Programming your own adventure games in Pascal
Post by: Wysardry on June 07, 2019, 09:03:48 pm
I recently saw a book on Amazon titled "Programming your own adventure games in Pascal" by Richard C. Vile, but it was written in 1984 and is only available in used condition.

Is this likely to be of any use for learning purposes?
Title: Re: Programming your own adventure games in Pascal
Post by: Noodly on June 07, 2019, 09:42:52 pm
Short answer = no.

Longer answer = only if you want to look into archaic text only adventures.

In the late 70's and early 80's some home computers had very little memory and couldn't support graphic games. So text only games were the only feasible way to get any kind of complexity.

They would generally follow a question and answer format:

Computer - you have 3 magic stars and the sword of wirth and need 2 more stars to complete this level. You have reached a fork in the road and must choose left or right. Down one fork you will find the golden safe which must be cracked to release the stars. Which way, left or right?

Player - right.

Computer - wrong choice! You are now confronted by Thaddy who is in a grumpy mood!

Etc etc
Title: Re: Programming your own adventure games in Pascal
Post by: Wysardry on June 08, 2019, 03:18:32 am
I get the impression that the book is about parser based text adventures, such as Adventureland by Scott Adams, rather than the multiple choice Choose Your Own Adventure type.

I am interested in learning more about how the former type are/were coded in Pascal. My main concern is whether the included code would work in Free Pascal and if it did, whether the methods used would still be considered good practice.
Title: Re: Programming your own adventure games in Pascal
Post by: Noodly on June 08, 2019, 08:07:11 am
I get the impression that the book is about parser based text adventures, such as Adventureland by Scott Adams, rather than the multiple choice Choose Your Own Adventure type.

I am interested in learning more about how the former type are/were coded in Pascal. My main concern is whether the included code would work in Free Pascal and if it did, whether the methods used would still be considered good practice.

Without having read the book I would say that the code is very likely to work in free pascal with minimal modificationl. It's likely that the author used turbo pascal at the time and fp has very good backwards compatibility with it. In which case I change my original short answer to yes.
Title: Re: Programming your own adventure games in Pascal
Post by: BobS on June 08, 2019, 09:08:18 am
While written in a dialect of LISP, the source code to these old text adventures is interesting if you're into that:
https://github.com/historicalsource?before=Y3Vyc29yOnYyOpK5MjAxOS0wNC0xNlQwNDowMzo1NCswMTowMM4KzcIl&tab=repositories (https://github.com/historicalsource?before=Y3Vyc29yOnYyOpK5MjAxOS0wNC0xNlQwNDowMzo1NCswMTowMM4KzcIl&tab=repositories)
Title: Re: Programming your own adventure games in Pascal
Post by: lucamar on June 08, 2019, 09:30:12 am
Interesting: prices on AbeBooks (https://www.abebooks.com/book-search/title/programming-your-own-adventure-games-pascal/) from around $12 to $1800 :o

BTW, the "Pascal" in the title is Apple Pascal, according to goodreads.com (https://www.goodreads.com/book/show/7676344-programming-your-own-adventure-games-in-pascal)
Title: Re: Programming your own adventure games in Pascal
Post by: 440bx on June 08, 2019, 09:48:45 am
Interesting: prices on AbeBooks (https://www.abebooks.com/book-search/title/programming-your-own-adventure-games-pascal/) from around $12 to $1800 :o
What an amazing world we live in.. $1800 and shipping isn't free... gotta love it. 

I suppose the buyer should be thankful that the seller isn't asking another $1800 for shipping... LOL
Title: Re: Programming your own adventure games in Pascal
Post by: RAW on June 08, 2019, 10:18:01 am
Quote
I suppose the buyer should be thankful that the seller isn't asking another $1800 for shipping... LOL
I guess you didn't read it very well .... New Hardware is included ... OF COURSE !!!  :P
Title: Re: Programming your own adventure games in Pascal
Post by: Wysardry on June 08, 2019, 05:36:51 pm
I'm in the UK, so I don't have as many options for buying it. I've added it to my Amazon UK wish list, and will keep an eye on the price. Its currently a little under £30 (around $45), so will need to drop by quite a lot to be worth buying.

Most other books I've seen on the topic are based on a dialect of unstructured BASIC.

BobS: I already had that site bookmarked, as I used to enjoy the old Infocom games. I think there are even a couple of ZIL compilers available. Unfortunately, Infocom used to have a separate interpreter for their games, so most of the actual processing was done was by that.
Title: Re: Programming your own adventure games in Pascal
Post by: kveroneau on June 08, 2019, 06:14:59 pm
If you are looking for Pascal relics, I highly recommend searching through the Internet Archives maintained by Jason Scott.  While I am 100% sure that the content he archives is 100% legal, I got in trouble for posting a link before.  But I am quite sure most of you here know of Jason Scott and the Internet Archive, he has archived a lot of old text books, and books from the past.  This is where I found copies of the original Turbo Pascal books I read as a child.  So, depending on the current copyright status of this particular Pascal book, it might eventually end up in the Internet Archive along with the other relics of our computing past.

Personal, what'd I love to see is old original Apple and Turbo Pascal games and programs being open sourced by their original developers and published for everyone to see.  It would be awesome to read through how these developers back in the 80s were able to create some rather amazing programs for the time, considering the memory and CPU of those old machines.  Nowadays most developers don't give a rats butt on how much memory and CPU their programs take, as long as it works, they assume that everyone running their software has a super computer in their home...  I personally still try to code with maximum efficiency.  For example, if I want a smaller program size, and I know what I am trying to do doesn't require some advanced Pascal features, I refrain from using the Object Pascal classes, and just do it the old school way.  Unlike most modern languages, Free Pascal actually gives the programmer the choice to use the OOP, or not.  You can still code a program using traditional Turbo Pascal semantics in Free Pascal, if you choose.  Free Pascal is great for both the retro hobby programmer, and the modern day OOP programmer. :D  I'm still holding out for an Apple ][ and Commodore 64 target machine in Free Pascal.

Also, depending on new you are to either programming or Pascal, any Pascal book should be an asset, as Pascal hasn't changed much in terms of the basic dialect and syntax.  I am sure the book will be great in say teaching how to parse text, calculate scores, keep a player inventory in a very efficient manner, and text adventures and MUDs aren't entirely dead.  A lot of people still really enjoy these types of games, as it is more akin to reading a book, than playing a traditional video game and thus stimulates the mind and enforces creativity.  A sentence in a text adventure can create millions of different visual images in the brain of different readers.  Each reader will perceive the sentence differently.
Title: Re: Programming your own adventure games in Pascal
Post by: Wysardry on June 08, 2019, 08:45:32 pm
It isn't so much that I'm deliberately seeking out Pascal relics, but more that there are so few new books on the subject. Most of the recent books on writing text adventures are for Python, it seems.

It's a shame that publishers don't republish more of their older books in electronic format. The distribution costs would be minimal, so they could charge less than $5 per book and still make a profit.

I also used to enjoy trying to program as efficiently as possible on the old 8-bit home computers. Level 9 Computing were probably the best at squeezing the largest amount of text into a machine with only 32 Kb of memory and a cassette player.

I'm not new to programming, but I haven't used Pascal before. From what I've learned so far, it seems to have all the features of ANSI Full BASIC plus a large selection of API libraries and it's much more cross platform.
Title: Re: Programming your own adventure games in Pascal
Post by: marcov on June 08, 2019, 10:40:29 pm
I recently saw a book on Amazon titled "Programming your own adventure games in Pascal" by Richard C. Vile, but it was written in 1984 and is only available in used condition.

Is this likely to be of any use for learning purposes?

Probably only a bit, some algorithms and concepts don't change. However the implementations can change with time, specially such long times. Heavier computers make more possible.

I think the Pascal angle will be the least useful. The dialect will be ancient, and the libraries probably don't exist anymore, and were overly simplistic anyway.

Decent container types, graphics etc are all parts of the default install now, and the first few GB of memory are usually also not the problem. That was quite different in 1984.

I think a more recent book that focusses on concepts with e.g. pseudo code will be more worthwhile.
Title: Re: Programming your own adventure games in Pascal
Post by: lucamar on June 09, 2019, 02:52:39 am
It's a shame that publishers don't republish more of their older books in electronic format. The distribution costs would be minimal, so they could charge less than $5 per book and still make a profit.

It's not so much the publishers--though your "economics" are a little off for them--as the authors themselves. After all, for lots (most?) of the old books most the rights reverted to the authors quite some time ago. It's they that have almost forgotten they ever wrote a book for the Apple II--and even if they remember, who can read those old tapes/disks?  :)

Not all are lost, of course: witness, for example, Cortessi's books on CP/M and Z80 programming, which he published in the web some time ago; or Jeff Duntemann's Turbo Pascal from the Square One which he's slowly (but surely) turning into the free FreePascal from the Square One as a "thank-you" for the community. It's just a question of careful search to find them.
Title: Re: Programming your own adventure games in Pascal
Post by: Wysardry on June 09, 2019, 07:02:37 am
marcov: I'm not so sure that the methods used to create text adventures have changed that much over the years. For example, Inform 7 (http://inform7.com/) still has the option to export games in Z-machine format which was used for Infocom's text adventures up until 1989 or so.

I haven't seen any books on creating text adventures that aren't aimed at a specific programming language or platform.


lucamar: There are utilities available to read older disk formats, although I'm not sure how easy it is to buy new magnetic disk drives these days. There are also emulators for most 8-bit machines.

I already managed to find a PDF of FreePascal from the Square One, and even in its unfinished state, it has been helpful so far. I also bought a PDF version of Getting Started with Lazarus IDE from Packt Publishing, which I haven't looked at yet.

Also on my radar is Getting Started with Lazarus and Free Pascal for the Kindle, but I'm not sure if Pascal Made Simple (by P K McBride) would be a better choice.
Title: Re: Programming your own adventure games in Pascal
Post by: lucamar on June 09, 2019, 07:55:08 am
lucamar: There are utilities available to read older disk formats, although I'm not sure how easy it is to buy new magnetic disk drives these days. There are also emulators for most 8-bit machines.

Getting the drive--which can be quite difficult, let me tell you--is only half the problem. The other half  (not counting normal, everyday, standard disk errors) is exemplified by this: take an old disk (say an Apple II one, for example, or a 5'25 from an old PC) and a cotton-pad; now very softly and lovingly caress the surface of the disk with the cotton--note: just a caress, don't get rough with it!.

If the cotton doesn't come away tinged a redish-brown then either you're very, very lucky and have a good disk which was safely stored or an utterly destroyed disk. That redish tint? That's the oxide layer which, by now, is merely resting on the vinyl surface, waiting for the smallest whiff of air (or the contact with a drive's reading head/cleaning pad) to take it away to la-la-land.  ;D

I have quite a lot of experience with old disks (and tapes and what-nots) and I can tell you that from 60% to 70% of them are not only unreadable but actually harmful for the crumbling drives in which they run. If you're not very careful you can end up with your desk (and/or the innards of the computer) covered with a layer of conductive reddish dust.
Title: Re: Programming your own adventure games in Pascal
Post by: BobS on June 09, 2019, 09:10:56 pm
I
Most other books I've seen on the topic are based on a dialect of unstructured BASIC.

BobS: I already had that site bookmarked, as I used to enjoy the old Infocom games. I think there are even a couple of ZIL compilers available. Unfortunately, Infocom used to have a separate interpreter for their games, so most of the actual processing was done was by that.
I've forgotten anything I knew about LISP, but still looking at the code it shouldn't be too hard to figure out what is going on and translate it to Pascal.  But I keep getting distracted by the text...especially Hitchhikers guide, some of which was written by the great man himself :) .
Title: Re: Programming your own adventure games in Pascal
Post by: lainz on June 09, 2019, 11:00:13 pm
A lot of years ago I wanted to make a point and click game that's a kind of adventure game, I made small stuff like single level games but this tool is great for it

https://www.adventuregamestudio.co.uk/

You can also download games made by other people and see.

"The AGS Editor is a Windows-based IDE for creating your games as quickly and easily as possible. Everything you need from importing graphics and writing game scripts right through to testing your game, under one roof!"

I know that these games can be made with Pascal, but if is just for fun and no need to stick to Pascal, I always prefer the most easy tool for each job.
Title: Re: Programming your own adventure games in Pascal
Post by: Wysardry on June 10, 2019, 02:26:38 am
BobS: I believe ZIL is based on MDL, but with fewer instructions.

As far as I know, decyphering just the ZIL code would not teach you everything about how Infocom games worked as they are mostly data with the Z-machine interpreter doing a lot of the actual processing.

I'm not 100% sure, but I think the parser is built into the Z-machine interpreter (which is different for each platform).


Lainz: I'm not really interested in creating point and click graphical adventures, as my artistic skills are virtually non-existent and making them cross platform is more complicated.

Text adventures are also more practical for lone developers.
Title: Re: Programming your own adventure games in Pascal
Post by: BobS on June 10, 2019, 02:51:57 am
It's definitely a derivative of Lisp, you can see that in code.  But really just reading the text gives you a pretty good idea of how it was all set up.  I haven't looked into that sort of thing for a long time, but really I'd think the basics are pretty simple.  Create your story; set up a map (linked list or sparse array); set up what happens in each node and the conditions (like what you might have to carrying) to get out of it are (to each connecting node) and you have the bulk of the work done.  Maybe I'm forgetting something, but I think that's pretty much all there was to it programming wise.  The text was by far the most important part, as that's all there was to spark the imagination.
Title: Re: Programming your own adventure games in Pascal
Post by: Wysardry on June 10, 2019, 03:58:55 am
MDL is based on Lisp, yes. It was created at MIT, I believe. Some of the people involved in its creation started Infocom and created a subset called ZIL (Zork Implementation Language).

I'm guessing that parsing the player's text instructions would be the hardest part, especially if it can handle more than just two word verb noun phrases like "open door". The Infocom parser could understand instructions like "take the leaflet then read it" or "take all except the red ball".
Title: Re: Programming your own adventure games in Pascal
Post by: BobS on June 10, 2019, 04:49:03 am
I don't think I ever played one that accepted more than two word commands with a limited number of commands available.  But really how many actual commands did they have?  Not counting synonyms.  I doubt it was many, things would have gotten too slow on those old systems. 
...
A short time later his brain slowly started functioning after his encounter with real life:
Now that I think about it I did have a game that was based on Zork (or something similar), but got frustrated because it kept saying, "sorry I don't understand that" or something to that effect most of the time when I typed in what seemed like a reasonable command sequence (like: "face east and pick up the moonstone").

I seem to remember there is a whole web site somewhere devoted to text adventures that I read about a few years ago...I wonder what they use to develop them now?
Title: Re: Programming your own adventure games in Pascal
Post by: Wysardry on June 10, 2019, 11:14:29 am
Even Colossal Cave Adventure had a vocabulary of almost 200 words (although they were all just three letters long). I have heard that some later games can understand over 1000 words.

There are a few popular sites on text adventures and interactive fiction, including Brass Lantern (http://brasslantern.org/) (quite dated), The Interactive Fiction Archive (https://www.ifarchive.org/) and Planet IF (https://planet-if.com/).

Info on many creation tools - both past and present - can be found in the Authoring System category of ifwiki (http://www.ifwiki.org/index.php/Category:Authoring_system).
Title: Re: Programming your own adventure games in Pascal
Post by: BobS on June 12, 2019, 06:26:23 am
Well there look to be some decent tools available, so anything done in Pascal along those lines might not be worth the effort if the goal is to write adventures and not to learn the programming techniques.  But if was me, I'd start with something simple.  Really the parsing is not going to be that hard...it's not like you're trying to translate from Russian to English or something.  Some long case and if structures could probably do a lot of it.  Main problem will be dealing with things like "pick up foot", does that mean pick up that statue foot object or is the character supposed to pick up a foot (maybe in prep for hopping) (this is a contrived example of course).  You're either going to be doing a lot of what they did on Star Trek when the computer keeps saying "specify" or have quite a bit of context awareness built in to figure out the ambiguities.  Anyway I'd just start with a simple two word command structure, and once you've got that all figured out expand it to to handle more complex structure with what you've learned.

Edit: Main thing I meant to say was thanks for the links, very interesting--than I got busy writing that over long paragraph  ::) .
Title: Re: Programming your own adventure games in Pascal
Post by: Wysardry on June 13, 2019, 04:46:56 am
I have several goals, one of which is to learn how to program in Pascal. Others include learning how to create more advanced text adventures games and hopefully to create a system that will make that easier for multiple platforms.

I'm not 100% happy with any of the currently available authoring systems, but I do intend to try a couple to learn how they work. My main issue with them is that they all use a separate interpreter/virtual machine, rather than compiling to a binary executable.

The development environments are also not very cross platform, which I find strange given that they aren't very resource intensive. At least two are written in .Net languages though.

I'll most likely start by trying to recreate one of the early public domain adventures - such as Colossal Cave Adventure - using an authoring system and then again from scratch in Pascal. I'll then move on to bigger and more complex games with better parsers.