Course:CPSC312-2024/Randomized Choose Your Own Adventure-prolog

From UBC Wiki

What is the problem?

We will be adapting our project 1 to prolog.

We are creating a randomized version of the classic game choose your own adventure. This game will produce adventure scenarios (in our case, a set of initial scenarios) based on changing probabilities, and randomized chance. The probability of each outcome will depend on your choices, therefore, there is a high probability of outcomes that are a logical consequence of your actions, but there exists small chances of getting totally random, unconnected outcomes. Depending on the choices that the player makes, they will add a certain number of points (each time they make a choice) which will in turn affect the end result that they get. There will also be a small chance of getting or losing a random item (kept track of in the inventory), each time the player makes a choice, which will add or subtract from their points.


Something extra (what we did)

  • We want to explore how well prolog works with storing state, so we will implement a small (random) inventory for players
  • Since we are reimplementing our project 1, we will also compare Haskell with prolog, and also re-implement our something extra from project 1 again (randomized, weighted choices), which is exploring randomization in SWI Prolog, and comparing it to Haskell.
    • An improvement (game-wise) from our first project, was we excluded completely non-logical outcomes from choices, while still keeping randomization through having a list of most logical outcomes as well as having a list of other more random possible outcomes (which would have different weights)


What did we learn from this

  • Compared to Haskell, we found that it was easier to impose conditions, to work with storing information, and to work with randomizations.
  • It was overall easier, because we did not spend as much time debugging mismatched types, since Prolog is dynamically typed, unlike Haskell.
  • Randomization was easier, since we didn’t have to worry about IO and types, and Prolog had some useful built-in functions to easily generate random numbers.
  • Working with user input was also simpler in Prolog, since user input was easily converted to other types, and user input in the TUI was more straightforward (i.e. Prolog did not need fixdel)
  • Debugging was not so straightforward in Prolog, because a lot of the time, bugs came in the form of our functions looping themselves, instead of any exception being thrown. This made looking for the source of errors more difficult, and involved a lot of print statements.


Possible Future extensions

  • Extend storylines (have more intricate storylines, more conditions in storylines, making more complex adventure).
  • Extend inventory (different inventory for different worlds)
    • Unlock new choices with inventory items
    • Inventory Items having functionality
  • Create a GUI


Work division

N/A


Links to code etc.

https://github.com/yangchristina/logic-rcyoa