Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
A browser-based Hearts card game with pluggable AI brains, including POMCP-based Monte Carlo search, playable online.
Hearts with HTML5 is a browser-based Hearts card game implemented in vanilla HTML5 and JavaScript, designed to serve as a platform for testing AI decision-making algorithms through its pluggable Brain system.
Hearts with HTML5 is a fully playable card game run in the browser, with a live instance hosted at http://hearts.yjyao.com/. The project's core is an Ai.js class that makes decisions by delegating to one of several Brain implementations. The game is written in HTML5 and JavaScript, and the source code is publicly available in a GitHub repository. It is primarily an educational and experimental project for implementing and comparing AI strategies in a classic trick-taking card game.
Ai.js class accepts different Brain implementations: SimpleBrain for simple greedy heuristics, McBrain for one-step look-ahead with sample generation and deterministic rollouts, and PomDPBrain for a Partially Observable Markov Decision Process (POMDP) solved with the POMCP algorithm.AsyncBrain wraps more time-consuming brains so they run in a web worker, keeping the browser UI responsive.Ai.js, Brain.js, and its subclasses provides a template for adding new decision-making strategies.This project is useful for AI researchers and students who want to see POMCP applied to a real game, for JavaScript developers interested in web-worker integration and modular AI design, and for anyone who enjoys playing Hearts online against an AI opponent.
SimpleBrain, McBrain, and PomDPBrain within the same game environment to study decision-making quality and computational cost.AsyncBrain wrapper to understand how to move heavy computations off the main thread using web workers.The game's decision-making is handled by the Ai.js class, which can be fed any Brain that extends the base Brain.js. AsyncBrain runs these brains inside a web worker when they become too slow. McBrain performs one-step look-ahead with sample generation and rollouts, assuming all players use the simple greedy strategy. PomDPBrain instead models the full game as a POMDP and solves it with the POMCP algorithm, also under the assumption that opponents use greedy play.
The game can be played online for free at http://hearts.yjyao.com/. The source code is publicly available in a GitHub repository for learning and modification.
The project implements three decision-making strategies: SimpleBrain (greedy heuristics), McBrain (one-step look-ahead with rollouts), and PomDPBrain (POMCP algorithm for POMDP solving). AsyncBrain wraps these for web-worker execution.
Currently the project is single-player against AI. The repository's TODO list notes that multi-player support is planned.
Since it is an HTML5/JavaScript project, you can download the repository and open the main HTML file in a browser, or serve the directory with any static file server. The live version is also available online.
