- Overview
- Features
- Installation
- How to Use
- Rules and Gameplay Mechanics
- Technical Details
- File Descriptions
- References
TCG-P+ is a C++-based probability analyzer designed to assist players of the Pokémon Trading Card Game Pocket (TCG-P) in making optimal in-game decisions. By leveraging parallel computing with OpenMP, TCG-P+ simulates and evaluates potential move outcomes in real time, providing actionable insights for players. The system is particularly useful for novice players facing the steep learning curve and time pressure of TCG-P's fast-paced gameplay.
-
Deck Input Module:
- Load and validate a 20-card deck from a file.
- Supports up to 2 copies of the same card.
-
Game State Analyzer:
- Input and track the current game state, including:
- Active and benched Pokémon.
- Energy attachments.
- Opponent's visible board state.
- Input and track the current game state, including:
-
Recommendation Engine:
- Provides real-time suggestions for:
- Optimal moves.
- Energy placements.
- Card usage.
- Provides real-time suggestions for:
-
Parallelized Simulations:
- Uses OpenMP to accelerate:
- Recursive decision tree evaluations.
- Monte Carlo simulations for probabilistic outcomes.
- Uses OpenMP to accelerate:
-
Meta-Deck Estimation:
- Automatically identifies potential opponent decks based on visible Pokémon and energy types.
This project is written in C++. I chose OpenMP to leverage multi-core parallelism for fast Monte Carlo simulations and recursive decision-tree evaluations, ensuring real-time probabilistic insights during gameplay. Its simple pragma-based approach integrates seamlessly into my existing C++ code without adding complex thread management.
- Clone or download the project files.
- Ensure the following files are present:
main.cppPokemonCard.hGameSimulation.handGameSimulation.cppFileParser.handFileParser.cppUtils.hCards.txt(card database)deck.txt(your deck)metaDecks.txt(meta-deck data)
- Prepare a 20-card deck in
deck.txt. - Ensure
Cards.txtcontains all card definitions. - Run the program and follow the prompts to:
- Load your deck.
- View your starting hand.
- Set up the initial board state.
- Input the current game state after each round:
- Active and benched Pokémon.
- Energy attachments.
- Attack actions and effects.
- Receive recommendations for:
- Optimal moves.
- Energy placements.
- Probabilistic insights into winning outcomes.
- Update the board state and log actions.
- View estimated opponent meta-decks based on their visible board.
- 20 cards per deck.
- Up to 2 copies of the same card.
- Draw Phase: Draw one card from the deck.
- Action Phase:
- Attach energy.
- Play supporter and item cards.
- Evolve Pokémon.
- Retreat Pokémon.
- Use abilities.
- Attack Phase: Use one attack from the active Pokémon.
- Earn 3 points to win:
- 1 point for defeating a regular Pokémon.
- 2 points for defeating an EX Pokémon.
OpenMP is used extensively in this project to accelerate computationally intensive tasks, ensuring real-time performance during gameplay. Key areas where OpenMP is applied include:
-
Recursive Decision Tree Evaluation:
- Simulates potential move sequences and outcomes.
- Parallelized to explore multiple branches of the decision tree simultaneously.
- Each branch is evaluated independently, making it ideal for multi-threading.
-
Monte Carlo Simulations:
- Estimates probabilities for card draws and move successes.
- Distributes iterations across threads for faster results.
- OpenMP's dynamic scheduling ensures efficient load balancing across cores.
-
Thread-Safe Data Management:
- Shared memory is used for caching game states.
- Critical sections and atomic operations ensure thread safety during updates.
By leveraging OpenMP, the program achieves significant speedups, enabling it to provide actionable insights within seconds, even for complex game states.
-
Card Database:
- Stored as an
std::unordered_map<std::string, Pokemon>. - Provides fast lookups for card attributes.
- Stored as an
-
Game State:
- Tracks the current board, hand, and deck.
- Includes energy attachments, attack actions, and meta-deck guesses.
-
Decision Trees:
- Represents possible move sequences and outcomes.
- Evaluated recursively with parallelization.
-
Source Code:
main.cpp: Entry point for the program.GameSimulation.cppandGameSimulation.h: Core game logic and simulations.FileParser.cppandFileParser.h: File parsing utilities for cards and decks.Utils.h: Helper functions for string manipulation.
-
Data Files:
Cards.txt: Database of all Pokémon, supporter, and item cards.deck.txt: Your 20-card deck.metaDecks.txt: Predefined meta-decks for opponent estimation.
-
Code Structure:
PokemonCard.h: Defines the core data structures for Pokémon, skills, abilities, and game state.GameSimulation.cpp: Implements gameplay logic, including decision tree simulations and meta-deck estimation.FileParser.cpp: Handles file input for loading cards and decks.Utils.h: Provides utility functions for string manipulation and parsing.
-
Gameplay Flow:
- Pre-Start: Load deck and initialize the game state.
- Round Updates: Input board state, energy attachments, and attack actions.
- Simulations: Evaluate potential moves and calculate winning probabilities.