Personal
project 1 of 7Game simulation · bots
TCG Simulator
Nov 2026 – Present · 1m · Author
A practice site for Pokémon TCG matchups: pick a deck, play a bot that runs the top decks of the tournament meta in the browser, then review the game turn by turn.
Highlights
- Rules engine in TypeScript where
apply(state, action)returns a new state. Card effects live in their own modules, and a coverage test fails when a card with effect text has no code. - The bot is a policy and value network that sees only what its side knows, with a look-ahead search over re-dealt hidden cards. It learned by imitating a rule-based bot, then by self-play PPO on a GPU, and thinks in a Web Worker.
- Review page: every finished game is kept in the browser with win% for each turn, the turns worth a second look and what the bot would have played, and any turn can be played again.
- A static Astro site with Svelte islands in Thai and English, with no back end and no sign-up.
- Vitest covers the rules, every card, a fuzz run and the bots. Playwright plays seeded games to the end on the production build.
100+
commits
6
meta decks
- TypeScript
- Astro
- Svelte
- Python
- PyTorch
- Vitest
- Playwright
Playing the bot
The player picks a deck from the meta or pastes a list, then picks the opponent or lets it be drawn by its share of recent tournaments. The game runs on a table like the real one: cards are dragged onto the board, a deck search shows the whole deck and Prize cards are chosen by hand.
The rules live in an engine that takes a state and an action and returns a new state. A choice in the middle of an effect becomes a pending question, and the same action runs again with the answer. That keeps a game replayable from its list of moves.
The opponent is one bot at one strength. A network scores every legal move from what its side can see, a search plays the best few forward over hidden cards dealt again from public information, and the value head picks. It never reads the player's hand or deck.
It is a fan site, not affiliated with The Pokémon Company. Card text and images load from TCGdex and pokemontcg.io.
Turn 6 of a game against the bot. Each card played is shown large for a moment. Pick both decks, or let the opponent be drawn by meta share. The end of a game, with a link to its review.
Reviewing a game
Every finished game is saved in the browser. The review shows win% for each turn, marks the turns where the player's line fell furthest from the bot's, and lists the moves the bot would have made with its reason.
Any turn can be opened on the table and played again from that position, and games can be exported and imported as files.
The review: a replay and win% for every turn. What was played on a turn and what the bot would play instead. Finished games are kept in the browser.
Decks from the tournament meta
Deck lists come from recent tournaments and each deck page says where its list is from. A script rebuilds the card data from the lists, and a test names every card the engine cannot play yet.
The bots also play each other thousands of times from the command line, which gives a matchup table with confidence intervals to compare with real tournament results.
The meta decks, ranked by their share of recent tournaments. A deck's full list. The landing page.