Course:312-2024/CardsAgainstHumanity

From UBC Wiki

Authors: Ryan, Sophia, and Isaac

What is the problem?

Cards Against Humanity is a card game where "players complete fill-in-the-blank statements, using words or phrases typically deemed offensive, risqué, or politically incorrect". Cards Against Humanity tends to be played in large groups and there are few ways it is accessible to single players who still feel like having fun. We wanted to recreate and implement this game in Haskell with a twist to it (playing against an AI)!

What is the something extra?

We use generative AI to bring life to the prompts - allowing users to have a more unique and fun experience! The user will be able to play against an AI that will select its own answer to a randomized question, and then in our version of the game, the user will decide which answer (either theirs or the AI's) is funnier.

What did we learn from doing this?

Through working on this project we were able to learn more about what it means to set up a game.

Backend Game Logic

One hurdle was taking input from both the player and from our csv files, and incorporating it into the game for further use. We got to learn more about how to use Haskell's input/output monad (and how to unsafely handle it). We also learned how to set up a loop over the game using case so the player could complete 10 rounds with each round right after the other. From our experience in implementing the game logic, using Haskell was good as the game states and state transitions are clearly defined.

UI

We learned how to build a graphical user interface in Haskell using the Gloss Library. We learned how to display text, drawings, buttons and integrate game state. We implemented game states, event handlers and UI that changed with each interaction and learned how to connect the logic and functionality to the backend game logic. From our experience in implementing the UI, using Haskell is feasible but not ideal, partly due to the library and also the restrictions functional programming has.

Work division

Isaac

  • Created the initial elements of the UI
  • Worked on the final UI
  • Created and updated the wiki page
  • Generated and added more questions and answers to csv files

Ryan

  • Generated the initial csv files for the cards
  • Helped to plan out the game logic
  • Refactored Cards.hs and updated to properly handle player input on the command line
  • Worked on the UI

Sophia

  • Planned out the game logic and how to make single player
  • Wrote the initial Cards.hs file on the game logic where the game could run fully on the command line
    • Included all necessary functions and data structures
  • Updated format for selection and voting pages to display the full text

Links to code etc.

https://github.com/ichung08/CardsAgainstAI