Skip to content

This simulator models UNO-style games using "Greedy Strategic" AI that prioritizes playing high-point cards first. It features a Chart.js dashboard for real-time win/play stats and an audit log that tracks player hand states before every turn to analyze AI behavior and strategy effectiveness.

Notifications You must be signed in to change notification settings

mtickle/card-game

Repository files navigation

Card Game Simulator & Analytics Dashboard

A high-performance React and Redux-based simulation engine designed to model, analyze, and visualize UNO-style gameplay. This project features "Greedy Strategic" AI agents, a real-time data visualization dashboard, and a persistent game auditing system.


Key Features

  • Strategic AI Players: AI agents use a "Greedy Strategic" sorting algorithm, prioritizing high-value cards (Wilds, Special cards) to minimize score penalties and maximize control.
  • Check-After-Draw Logic: Mirroring human play, AI agents evaluate cards immediately after drawing. If a playable card is drawn, it is played in the same turn, significantly increasing game efficiency.
  • Real-Time Analytics Dashboard: Built with Chart.js, providing insights into:
    • Win Distribution: Tracking player success rates to identify first-player advantage or AI bias.
    • Granular Card Frequency: Bar charts tracking the play rates of every individual card value (0-9 and action cards).
    • Game Duration Trends: Monitoring turns-per-game to evaluate simulation speed and competitiveness.
  • Advanced Turn Auditing: A comprehensive TurnLogTable that provides:
    • Hand Snapshots: View the exact state of a player's hand before every play, rendered as styled card assets.
    • Player Filtering: Drill down into specific AI behaviors by filtering the log by player.
    • Outcome Summary: Clear visual indicators for winning plays (🏆) and a final Game Outcome summary for all participants.
  • Data Persistence: Integrated with Auth0 for user identity and a database backend to maintain longitudinal statistics across sessions.

Tech Stack

  • Frontend: React (Hooks, Context, Memoization)
  • State Management: Redux Toolkit (Slices, Thunks)
  • Styling: Tailwind CSS
  • Charts: Chart.js / react-chartjs-2
  • Auth: Auth0
  • Storage: Database (Primary) / LocalStorage (Backup Turn Logs)

AI Strategy: "The High-Value Purge"

The simulation employs a strategic sorting mechanism. Before searching for a playable card, the AI sorts its hand based on point values:

  1. 50 Points: Wilds & Wild Draw Fours (Highest Priority)
  2. 20 Points: Skips, Reverses, Draw Twos
  3. 0-9 Points: Number cards (Lowest Priority)

By prioritizing these cards, the AI avoids getting "caught" with high-value cards at the end of the game and maintains better control over the game's flow.


Analytics Summary

The introduction of strategic sorting and draw-time evaluation led to:

  • Balanced Win Rates: Improving the AI's efficiency nearly eliminated the inherent first-player advantage, leading to a much more even win distribution.
  • Score Optimization: Average losing scores dropped by approximately 5 points as AI players became better at purging high-value cards.
  • Strategic Depth: While game length remained stable, the frequency of defensive plays (Skips/Reverses) increased, indicating a more competitive "tug-of-war" dynamic.

Getting Started

  1. Clone the repository.
  2. Install dependencies: npm install
  3. Set up your .env with Auth0 credentials.
  4. Launch the simulation: npm start

About

This simulator models UNO-style games using "Greedy Strategic" AI that prioritizes playing high-point cards first. It features a Chart.js dashboard for real-time win/play stats and an audit log that tracks player hand states before every turn to analyze AI behavior and strategy effectiveness.

Resources

Code of conduct

Stars

Watchers

Forks

Contributors

Languages