Live data from Hacker News

How to program a text adventure in C

helderman.github.io

21–30 of 56 posts

Re: How to program a text adventure in C

#21
post #15

The best way to implement a text adventure in C would be to implement a simple lisp interpreter in C and then implementing the actual game in a lisp DSL. Lisp lends itself surprisingly well to this, and defining game logic declaratively instead of imperatively is much more intuitive. Here are a few examples: [1] http://www.ulisp.com/show?383X [2] https://github.com/mswift42/MetalHead [3] https://github.com/xlxs4/lisp…

That's like saying the best way to drive to New York is to drive down the block to the train station and then take a train lol

Which, generally, is true.

Re: How to program a text adventure in C

#22
post #15

The best way to implement a text adventure in C would be to implement a simple lisp interpreter in C and then implementing the actual game in a lisp DSL. Lisp lends itself surprisingly well to this, and defining game logic declaratively instead of imperatively is much more intuitive. Here are a few examples: [1] http://www.ulisp.com/show?383X [2] https://github.com/mswift42/MetalHead [3] https://github.com/xlxs4/lisp…

I haven’t used lisp is 30 years, so help me understand/remember why this would be easier than say C++ or any other language with object inheritance and virtual functions. Is there something else about it?

Re: How to program a text adventure in C

#23
Many years ago (circa 1993) I ported the original Colossal Cave adventure by Crowther and Woods to TADS, a language created by Mike Roberts specifically for authoring text adventures. (Colossal Cave just came up recently here.)

https://ifdb.org/viewgame?id=c896g2rtsope497w

Graham Nelson ported my port to his Inform language, and Inform is probably your best choice if what you actually want to do is write a (plain text) adventure game.

If you want to learn C programming, writing a text adventure in C would be a fun learning project! But aside from pedagogy there’s no real reason to write a text adventure in anything other than Inform, TADS, etc. Not only is it much easier to use one of these purpose-built languages, with Inform you get multi-platform compatibility going back to the 8-bit era for free!

Personally if I had any free time, I’d be more interested in looking at how to use a frontier LLM like llama as an integral part of a text adventure. There was something like this using GPT-2 circulating on here a while back, but it was pretty rough.

However, it’s clear that if you figured out how to precisely control the LLM so it didn’t produce crazy stuff, you could realize the dream of truly realistic NPCs in these games. Text adventures would seem to be a perfect laboratory for experimenting with this.

Re: How to program a text adventure in C

#24
post #15

The best way to implement a text adventure in C would be to implement a simple lisp interpreter in C and then implementing the actual game in a lisp DSL. Lisp lends itself surprisingly well to this, and defining game logic declaratively instead of imperatively is much more intuitive. Here are a few examples: [1] http://www.ulisp.com/show?383X [2] https://github.com/mswift42/MetalHead [3] https://github.com/xlxs4/lisp…

Or replace large part of this code with lex and yacc and stick with C.

Re: How to program a text adventure in C

#25
post #22
post #15

The best way to implement a text adventure in C would be to implement a simple lisp interpreter in C and then implementing the actual game in a lisp DSL. Lisp lends itself surprisingly well to this, and defining game logic declaratively instead of imperatively is much more intuitive. Here are a few examples: [1] http://www.ulisp.com/show?383X [2] https://github.com/mswift42/MetalHead [3] https://github.com/xlxs4/lisp…

I haven’t used lisp is 30 years, so help me understand/remember why this would be easier than say C++ or any other language with object inheritance and virtual functions. Is there something else about it?

OO is absolutely the wrong paradigm for interactive fiction. Writing a text adventure has been my favorite way to experiment with a new language for decades now, and I’ve gone down the OO rabbit hole too many times. For this use case, you want something more like an ECS, so that a single entity can be more than one kind of thing at the same time. Consider a talking robotic vehicle. It is an object in the world: the player can interact with it from the outside. It is a room, with contents: the player can be inside it. It is an NPC: the player can speak with it. Trying to accommodate that in an OO inheritance hierarchy has always tied my code—and brain—in knots. An ECS-like architecture can handle it easily.

Re: How to program a text adventure in C

#26

Many years ago (circa 1993) I ported the original Colossal Cave adventure by Crowther and Woods to TADS, a language created by Mike Roberts specifically for authoring text adventures. (Colossal Cave just came up recently here.) https://ifdb.org/viewgame?id=c896g2rtsope497w Graham Nelson ported my port to his Inform language, and Inform is probably your best choice if what you actually want to do is write a (plain tex…

>8 bit

with Puny Inform6 or limiting Inform6, yes. If not, it's suicidal, even for v3 games. But, from Amiga and Atari machines, most v5 and v8 games if not all will run great.

Re: How to program a text adventure in C

#27
post #2

I was wondering: does anybody know if there are any good resources for writing a good text adventure? Any nice tips and tricks? Mainly related to the content. I guess it overlaps with "writing a good novel", but I bet there're some specific advices that can be applied to the text adventure. I wanted to write my text adventure, but I'd offer reader to have multiple options, especially for those who are not really prac…

Ron Gilbert's 1989 "Why Adventure Games Suck And What We Can Do About It" https://grumpygamer.com/why_adventure_games_suck/

Text adventures are not graphical adventures. Text games don't have the linearity and constraints of a graphical one.

Compare Anchorhead, Devours, Spider and Web... with most point and click games.

Re: How to program a text adventure in C

#28
post #15

The best way to implement a text adventure in C would be to implement a simple lisp interpreter in C and then implementing the actual game in a lisp DSL. Lisp lends itself surprisingly well to this, and defining game logic declaratively instead of imperatively is much more intuitive. Here are a few examples: [1] http://www.ulisp.com/show?383X [2] https://github.com/mswift42/MetalHead [3] https://github.com/xlxs4/lisp…

Sorry but Inform6, which itself is a distant cousin on methodology against ZIL and ZIL itself to Lisp, it's far better than CL for these kind of games.

The English (and Spanish library -grammar, object and token translations- with INFSP6) it's something else. Among Inform Beginners' Guide, with DM4.pdf you can set anything, even new grammars, or a Tetris, if you want to dwell into low-level Inform6 functions.

Inform6 gives you literal game objects and attributes for free. The most literal OOP language ever. And the generated ZMachine games/ROMs will run from a m68k Amiga to an Iphone.

Re: How to program a text adventure in C

#29
post #26

Many years ago (circa 1993) I ported the original Colossal Cave adventure by Crowther and Woods to TADS, a language created by Mike Roberts specifically for authoring text adventures. (Colossal Cave just came up recently here.) https://ifdb.org/viewgame?id=c896g2rtsope497w Graham Nelson ported my port to his Inform language, and Inform is probably your best choice if what you actually want to do is write a (plain tex…

>8 bit with Puny Inform6 or limiting Inform6, yes. If not, it's suicidal, even for v3 games. But, from Amiga and Atari machines, most v5 and v8 games if not all will run great.

You would probably do better on 8-bits by using ZIL which is actually feasible these days thanks to ZILF (and the leaked ZIL source code of the original Infocom games to look at).

Re: How to program a text adventure in C

#30
post #4
post #2

I was wondering: does anybody know if there are any good resources for writing a good text adventure? Any nice tips and tricks? Mainly related to the content. I guess it overlaps with "writing a good novel", but I bet there're some specific advices that can be applied to the text adventure. I wanted to write my text adventure, but I'd offer reader to have multiple options, especially for those who are not really prac…

For the technical side of things, use ink script. There's an editor, plugins and it's a mature project. For the creative side I would recommend trying out all kinds of things. Should your player be able to get stuck/into a dead end? Will players play once or many times. Can you "win" your game or is it more of a narrative? How do you want the player to feel! For some more specific ideas, think about how your game bra…

[deleted]
Post reply on HN