Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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-spels/blob/main/spel.el



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.


Thanks - I hadn’t heard of ECS before. That expanded my mind :)


That was my reaction when I first came across it.


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.


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.


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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: