From UBC Wiki


Authors: Johnson Nguyen, Vincent Sheu, Fareez Sanif

What is the problem?

Basically Zork in Prolog.
We'll find out if logical programming will allow us to build a text based world that we can interact with.
This includes but is not limited to, exploring new areas in the world, finding items in these areas and using these items to change the world.

The overall goal of the projects is to make a simple game that is easily extendable so any budding level designer can
create a game that is as large and extensive as they wish. This includes easily adding rooms, adding new objects that players can interact with, new commands and different end game conditions.

What is the something extra?

We should be able to extend our program (comprised of a natural language processor and game rules) and knowledge base to make a fully fledged game (or at the minimum, a single level of the game) out of it.
This will include goals for the players to achieve and possible a story of sorts

What did we learn from doing this?

(This should be written after you have done the work.) What is the bottom-line? Is logic programming suitable for (part-of) the task? Make sure you include the evidence for your claims.

We found out that is is possible to code a text based adventure using Prolog
However, there were a few downsides to a text-based-adventure game built with prolog:
First, after every command the user inputs, true must be printed in SWI-Prolog, which might confuse some players.
Second, because prolog does not give output unless given input, we were unable to create an "automatic start" that would launch the game as soon as the .pl file is launched.
Third, prolog does not handle unexpected commands gracefully. We were unable to create a "catch-all" function that would catch every possible input and then process it. This means that when the player types a non-existing command, they receive a confusing error.

Even so, with the use of triples, we found it was very easy to extend levels, create objects and make new properties to objects for them interact with the world.
On the other hand, we also realized that it wasn't suitable to use a natural language processor to parse the commands, because the format of input expected by a NLP is quite different (more complicated) from the commands we want players to use. In the end, it was decided that the most suitable solution was to provide players with a limited set of game commands that we teach them to use.

Bottom-line is that it is very much possible to build a fully functional text based game in SWI-Prolog as it has much of the tools and input windows ready to be used, but it has clear limitations as well.