Authors: James Zang, Connor Quigg, Aidan Frost
What is the problem?
We will be investigating the possibility of using the Haskell language for adventure-style interactive games with graphical elements.
To explore this concept, we plan on implementing a re-scaled version of the Oregon Trail game, with user-controlled events and progression. We plan on using graph data structures to encapsulate different route/event possibilities throughout the execution of the game and incorporate random event generation to impose new, unexpected challenges to the user.
What is the something extra?
We plan to focus our efforts on a GUI for better user interactivity. Most likely, we will build on top of an existing library like https://github.com/jtdaugherty/brick or https://hackage.haskell.org/package/gloss. The original Oregon Trail game (check it out at https://archive.org/details/msdos_Oregon_Trail_The_1990) features a custom Terminal-style UI, so we will draw inspiration from that.
What did we learn from doing this?
We found that Haskell did a satisfactory job in implementing a retro game with a GUI. There were some structural issues we had to overcome regarding some functionality that required using IO types. We decided to use the Gloss library as it was an OpenGL wrapper that allowed us to draw text and images on the screen easily from within Haskell using the library’s API.
The pseudo-random numbers were difficult and required IO, we found a way around this by using some of the user input values (party member names) as a seed for a pseudo-random number function that did not require IO. For loading of external images, we were forced to use IO by loading all the graphics prior to launching the game and kept these as a list in the world state for use during the game. During testing, we learned that the functions relying on IO were slightly less stable than pure functions and required more supervision.
Working without direct IO had interesting implications for dealing with user input. We learned that careful case handling and pattern matching could provide user input functionality by matching key events to a user input field in the world record and concatenating the key pressed to the user input field.