Flangy > Software Development > AdHoc

AdHoc

Download: adhoc.zip

AdHoc is a small experiment in modeling a text adventure game in Prolog, derived from this article from PC AI. I wrote it as my final project for Intro to AI at CWRU. I'll be the first to admit that it has nothing to do with AI, but the article was given as a project choice.

The class was my first exposure to a non-imperative programming that actually required coding. As opposed to the LOGO units in elementary school which only used immediate mode commands, or other projects where I only had to read the languages, not code in them.

As someone who is more interested in games than Prolog, here's the thing that sucks about AdHoc (and most other projects you can find around the web based on that article): there's no string/grammar parser. You interact with the game world by running Porlog predicates, not by typing sentances into a parser. So you type take(green_potion). instead of take green potion.

If you actually want to author a text adventure, I'd recommend Inform.

Files

crown.pl: This is the sample game. It shows how to set up rooms, items, and daemons. To run: consult('crown.pl').

game.pl: The game "engine." Has functions to deal with inventories (player and container), health and death, and activates daemons when appropriate. Has some example objects and verbs.

list.pl: The ubiquitous Prolog list functions. I think similar list code appears in every Prolog introduction.

output.pl: Some functions to output lists of stuff.

lverbs.pl: Abbreviations for direction commands and some others.

parse.pl: Sample parsing loop. Not actually used in the game.

How did I do?

I ended up with an A on the project and in the class, so I guess the code was good enough for the purpose at hand.