⚡ No Installation or Download Required!
Play immediately on your phone (iPhone or Android) or computer with zero setup, zero ads, and zero account sign-up.📲 Install as Mobile App: On your phone, tap Share (iOS Safari) or
⋮Menu (Android Chrome) ➔ "Add to Home Screen" to play full-screen offline anytime.
An open-source, mathematically fair implementation of the classic Hearts trick-taking card game. Built to solve the widespread frustration with commercial Hearts games that secretly bias and coordinate bots against the human player.
Almost all commercial Hearts mobile and web apps use rigged AI:
- Rubber-Banding Collusion: The bots secretly peek into your hidden hand and collude to dump penalty cards (the Queen of Spades ♠Q and Hearts ♥) on the real human player.
- Artificial Difficulty: Instead of making bots smarter, commercial apps simply handicap the human or coordinate discards against Seat 0.
- Flawed Dumping Heuristics: In naive implementations, bots simply dump cards on whoever is winning the current trick, turning active players into constant lightning rods.
Fair Hearts is engineered on three non-negotiable principles:
- Zero Information Leakage ("No-Peeking"):
Every AI function receives strictly its own hand and the publicly played cards. There is literally no code path in the engine that allows a bot to look at opponent cards. - Seat Anonymity:
The AI algorithms evaluate all 4 seats as identical anonymous competitors. The bot has no concept of whether a player is human or AI. - Independent Self-Interest:
Every bot plays solely to minimize its own score or execute a legal "Shoot the Moon". When dumping penalty cards, bots target the current match leader on the scoreboard (the biggest threat), never a fixed seat.
| Tier | Name | Engine & Algorithmic Design |
|---|---|---|
| Tier 1 | Casual (Easy) | Rule of Thumb (Heuristics): Plays legal cards, ducks when points appear, sheds high cards when void. Does not count cards or remember past voids. |
| Tier 2 | Strategic (Normal) | Card Counting & Void Tracking: Tracks all 52 cards, detects opponent voids, manages Queen of Spades danger, targets the match leader, and actively defends against opponent moon shots. |
| Tier 3 | Master (Hard) | Perfect Information Monte Carlo (PIMC): Runs 35+ void-constrained determinizations per decision, simulating future trick trajectories to mathematically minimize expected penalty points. |
Fair Hearts is built with zero external dependencies using pure HTML5, modern CSS3, and vanilla JavaScript:
- Windows / macOS / Linux: Open
index.htmlin Chrome, Firefox, Safari, or Edge. - Android: Open in Chrome, tap the
⋮menu, and select "Add to Home Screen" or "Install app". It installs as a lightweight Progressive Web App (PWA) that launches in full-screen and works 100% offline! - iOS: Open in Safari, tap the Share icon, and select "Add to Home Screen".
- Card Passing Rotation: Round 1 (Pass Left) $\rightarrow$ Round 2 (Pass Right) $\rightarrow$ Round 3 (Pass Across) $\rightarrow$ Round 4 (No Pass / Keep) $\rightarrow$ repeats.
- Opening Lead: The player holding the 2 of Clubs (2♣) must lead the first trick.
- Blood Rule (Trick 1): No penalty points (Hearts or ♠Q) may be played on the first trick unless a player has only points.
- Hearts Breaking: Hearts cannot be led until a Heart or the Queen of Spades has been played on a previous trick, or the leader has only Hearts.
- Shooting the Moon: Collecting all 13 Hearts + the Queen of Spades gives 0 points to the shooter and +26 points to every opponent!
- Game Over: The match ends when any player hits 100 points. Lowest score wins!
Clone the repository and open index.html in any web browser:
git clone https://github.com/ibrahimali111/fair-hearts.git
cd fair-hearts
# Start a simple local server (optional)
python3 -m http.server 8080Open http://localhost:8080 in your browser.
Most commercial Hearts apps and websites use "rubber-banding" algorithms. Instead of making bots smarter, the AI peeks at your hidden hand and coordinates discards to dump the Queen of Spades (♠Q) and penalty Hearts onto the human player to artificially suppress win rates.
- Zero Information Leakage: Bot algorithms receive only their own 13 cards and publicly played cards. There is no code path that allows bots to peek at opponent cards.
- Seat Anonymity: To the AI, all four seats are identical anonymous competitors. The bot has no concept of whether a seat is human or bot.
- Independent Self-Interest: Every bot plays strictly to minimize its own score or execute a legal "Shoot the Moon". When shedding penalty cards, bots target whoever is leading the match on the scoreboard, never a specific seat.
- Open Source Code: Every line of card selection logic is open and inspectable in
js/ai-easy.js,js/ai-normal.js, andjs/ai-hard.js.
No! Fair Hearts runs 100% in your browser with zero installation. Open https://ibrahimali111.github.io/fair-hearts/ on any phone (iPhone / Android) or computer. You can also tap "Add to Home Screen" to install it as a standalone app that works offline.
Hard difficulty implements Perfect Information Monte Carlo (PIMC) search. For every decision, the engine samples dozens of void-constrained determinizations of the hidden cards, runs rollouts through future trick sequences, and mathematically chooses the card with the lowest expected penalty points.
MIT License — Copyright (c) 2026 ibrahimali111.
0 comments
log in to comment.