Prisoner's Dilemma Game - A Reddit Interactive Experience

Inspiration

The classic Prisoner’s Dilemma is one of the most well-known problems in game theory. It explores the conflict between individual self-interest and collective benefit, making it a fascinating experiment in human decision-making. Inspired by this, we wanted to create an interactive Reddit post where users can play a 7-round Prisoner’s Dilemma game, either against a bot or another player.

What We Learned

Building this project taught us several key lessons:

  • React + Devvit Integration: Implementing UI elements in Devvit required learning how Devvit blocks work alongside React state management.
  • Game State Management: Handling persistent game states and ensuring seamless user interactions.
  • UI/UX Design in Reddit Apps: Making the UI intuitive and engaging while working within Devvit's constraints.
  • Game Theory Concepts: Reinforcing knowledge of cooperation vs. betrayal dynamics.

How We Built It

  • Game Logic: The PrisonersDilemmaGame class manages rounds, scores, and player decisions.
  • Leaderboard: Stores player scores dynamically for tracking performance.
  • Reddit Integration: Users can start a new game, interact through an intuitive UI, and see results in real-time.

Challenges We Faced

  • State Persistence: Ensuring the game state persisted correctly across interactions.
  • Devvit UI Limitations: Devvit blocks limit traditional UI flexibility, so we had to design around that.
  • Balancing UI Simplicity & Interactivity: We aimed to keep the UI clean while making the game engaging.

Future Improvements

--UI: yet to work on

  • Asynchronous Multiplayer Mode: Allowing two players to play in different sessions.
  • AI Enhancements: Making the bot more strategic by implementing tit-for-tat or reinforcement learning.
  • Enhanced Leaderboards: Storing persistent leaderboards across different games and users.

Built With

Share this project:

Updates