Course:CPSC312-2019/Choose Your Own Adventure

From UBC Wiki

Authors: Tiger Oakes, Meng Hsun "Daphne" Liu

What is the problem?

You are lost in a Prolog Convention and need to use the bathroom. You must explore the area and query different paths until you can discover the best way there. This will be a Choose your own Adventure game where the player can try different paths.

What is the something extra?

We added some special behaviour depending on the state of the player. Our options and paths are designed so that the player must accomplish a certain task before they can reach the ending. Additionally, we are able to have multiple branches link to a given path. We even have paths that directly lead into another state without input from the player. Finally, we have a special indicator for when the game is over. In that case, our actions change to indicate the player must end or restart the game.

What did we learn from doing this?

For our game, we needed two key features, the abilities for the user to interact through keyboard input and print out instructions through console output. Prolog offers both of these, and we took advantage of them.

Our game is a very rudimentary path-finding game. The user would make choices at each state, leading them to another state. We learned that Prolog is a suitable language to represent state, query user's location, and writing simple logic for moving between states. In particular, we found it intuitive to represent a path, moving from the old location to the new location through a command.

Since Prolog is designed for static queries, we had a little trouble figuring out how to mutate state in order to represent the player's current location. We eventually learned how to use retract and assert to accomplish this.

Links to code etc