3a8b2efd-8df2-4277-9336-5d97408d6574
This commit is contained in:
1091
.gitignore
vendored
1091
.gitignore
vendored
File diff suppressed because it is too large
Load Diff
113
CMakeLists.txt
Normal file
113
CMakeLists.txt
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
|
||||||
|
# Project definition
|
||||||
|
project(PokemonBattleSimulator
|
||||||
|
VERSION 0.1.0
|
||||||
|
DESCRIPTION "High-performance Pokemon battle simulator for Generation 1"
|
||||||
|
LANGUAGES CXX
|
||||||
|
)
|
||||||
|
|
||||||
|
# Set C++ standard
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
# Add custom CMake modules
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
||||||
|
|
||||||
|
# Build options
|
||||||
|
option(BUILD_TESTS "Build unit tests" ON)
|
||||||
|
option(BUILD_BENCHMARKS "Build performance benchmarks" OFF)
|
||||||
|
option(BUILD_EXAMPLES "Build example programs" ON)
|
||||||
|
option(ENABLE_SANITIZERS "Enable runtime sanitizers" OFF)
|
||||||
|
option(ENABLE_STATIC_ANALYSIS "Run static analysis tools" OFF)
|
||||||
|
option(ENABLE_COVERAGE "Generate code coverage reports" OFF)
|
||||||
|
|
||||||
|
# Include custom CMake modules
|
||||||
|
include(CompilerWarnings)
|
||||||
|
include(StaticAnalysis)
|
||||||
|
|
||||||
|
# Set default build type
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Configure compiler warnings
|
||||||
|
set_project_warnings()
|
||||||
|
|
||||||
|
# Enable static analysis if requested
|
||||||
|
if(ENABLE_STATIC_ANALYSIS)
|
||||||
|
enable_static_analysis()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Find dependencies
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
|
# Add subdirectories
|
||||||
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
# Conditionally build tests
|
||||||
|
if(BUILD_TESTS)
|
||||||
|
enable_testing()
|
||||||
|
add_subdirectory(tests)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Conditionally build benchmarks
|
||||||
|
if(BUILD_BENCHMARKS)
|
||||||
|
add_subdirectory(benchmarks)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Conditionally build examples
|
||||||
|
if(BUILD_EXAMPLES)
|
||||||
|
add_subdirectory(examples)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Installation configuration
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
# Install headers
|
||||||
|
install(DIRECTORY include/
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Export targets
|
||||||
|
install(EXPORT PokemonSimTargets
|
||||||
|
FILE PokemonSimTargets.cmake
|
||||||
|
NAMESPACE PokemonSim::
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PokemonSim
|
||||||
|
)
|
||||||
|
|
||||||
|
# Generate and install config files
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
|
||||||
|
write_basic_package_version_file(
|
||||||
|
PokemonSimConfigVersion.cmake
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
COMPATIBILITY SameMajorVersion
|
||||||
|
)
|
||||||
|
|
||||||
|
configure_package_config_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/PokemonSimConfig.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/PokemonSimConfig.cmake
|
||||||
|
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PokemonSim
|
||||||
|
)
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/PokemonSimConfig.cmake
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/PokemonSimConfigVersion.cmake
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PokemonSim
|
||||||
|
)
|
||||||
|
|
||||||
|
# CPack configuration for packaging
|
||||||
|
include(cmake/packaging/DEB.cmake)
|
||||||
|
include(cmake/packaging/RPM.cmake)
|
||||||
|
|
||||||
|
set(CPACK_PACKAGE_NAME "pokemon-battle-simulator")
|
||||||
|
set(CPACK_PACKAGE_VENDOR "Pokemon Sim Team")
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "High-performance Pokemon battle simulator")
|
||||||
|
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
||||||
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||||
|
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
|
||||||
|
|
||||||
|
include(CPack)
|
||||||
47
README.md
47
README.md
@@ -1 +1,46 @@
|
|||||||
this is a pokemon repo
|
# Pokemon Battle Simulator (Gen 1)
|
||||||
|
|
||||||
|
A high-performance C++ library for simulating Pokemon battles from Generation 1 with maximum efficiency.
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
├── src/ # Core C++ source files
|
||||||
|
├── include/ # C++ header files
|
||||||
|
├── data/ # Pokemon data, moves, types, etc.
|
||||||
|
├── tests/ # Unit and integration tests
|
||||||
|
├── benchmarks/ # Performance benchmarks
|
||||||
|
├── tools/ # Python tooling and utilities
|
||||||
|
├── cmake/ # CMake configuration files
|
||||||
|
├── docs/ # Documentation
|
||||||
|
├── examples/ # Usage examples
|
||||||
|
└── build/ # Build artifacts (git-ignored)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Features (Planned)
|
||||||
|
|
||||||
|
- Complete Generation 1 Pokemon data
|
||||||
|
- Accurate battle mechanics simulation
|
||||||
|
- High-performance battle engine
|
||||||
|
- Type effectiveness system
|
||||||
|
- Move and ability implementations
|
||||||
|
- AI battle strategies
|
||||||
|
- Performance benchmarking tools
|
||||||
|
|
||||||
|
## Build Requirements
|
||||||
|
|
||||||
|
- C++17 or later
|
||||||
|
- CMake 3.15+
|
||||||
|
- Python 3.8+ (for tooling)
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir build && cd build
|
||||||
|
cmake ..
|
||||||
|
make
|
||||||
|
```
|
||||||
|
|
||||||
|
## Development Tools
|
||||||
|
|
||||||
|
Python scripts in the `tools/` directory provide data processing, validation, and development utilities.
|
||||||
65
benchmarks/README.md
Normal file
65
benchmarks/README.md
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
# Benchmarks Directory (`benchmarks/`)
|
||||||
|
|
||||||
|
This directory contains performance benchmarks and profiling tools for the Pokemon battle simulator.
|
||||||
|
|
||||||
|
## Planned Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
benchmarks/
|
||||||
|
├── core/ # Core system benchmarks
|
||||||
|
│ ├── battle_speed.cpp # Battle simulation speed
|
||||||
|
│ ├── pokemon_creation.cpp # Pokemon instantiation
|
||||||
|
│ ├── move_calculation.cpp # Move damage calculations
|
||||||
|
│ └── type_lookup.cpp # Type effectiveness lookups
|
||||||
|
├── data/ # Data loading benchmarks
|
||||||
|
│ ├── json_parsing.cpp # JSON data parsing speed
|
||||||
|
│ └── data_caching.cpp # Cache performance
|
||||||
|
├── ai/ # AI performance benchmarks
|
||||||
|
│ ├── ai_decision_time.cpp # AI move selection speed
|
||||||
|
│ └── minimax_depth.cpp # Minimax algorithm scaling
|
||||||
|
├── memory/ # Memory usage benchmarks
|
||||||
|
│ ├── memory_usage.cpp # Memory footprint analysis
|
||||||
|
│ └── allocation_speed.cpp # Dynamic allocation performance
|
||||||
|
├── scenarios/ # Real-world scenario benchmarks
|
||||||
|
│ ├── tournament.cpp # Tournament simulation
|
||||||
|
│ └── monte_carlo.cpp # Monte Carlo battle analysis
|
||||||
|
├── results/ # Benchmark results and reports
|
||||||
|
│ ├── baseline/ # Baseline performance data
|
||||||
|
│ └── reports/ # Generated performance reports
|
||||||
|
└── CMakeLists.txt # Benchmark build configuration
|
||||||
|
```
|
||||||
|
|
||||||
|
## Benchmarking Framework
|
||||||
|
|
||||||
|
- **Google Benchmark**: Primary benchmarking library
|
||||||
|
- **Automated Regression Detection**: Performance alerts on slowdowns
|
||||||
|
- **Multiple Metrics**: Time, memory, CPU usage, cache misses
|
||||||
|
- **Statistical Analysis**: Multiple runs with confidence intervals
|
||||||
|
|
||||||
|
## Key Performance Targets
|
||||||
|
|
||||||
|
### Battle Simulation
|
||||||
|
- **Target**: 1M+ battles per second on modern hardware
|
||||||
|
- **Memory**: < 1KB per Pokemon instance
|
||||||
|
- **Latency**: < 1µs per move calculation
|
||||||
|
|
||||||
|
### Data Loading
|
||||||
|
- **Target**: < 100ms to load all Gen 1 data
|
||||||
|
- **Memory**: Efficient data structures with minimal overhead
|
||||||
|
- **Caching**: Fast lookup tables for frequently accessed data
|
||||||
|
|
||||||
|
### AI Performance
|
||||||
|
- **Random AI**: < 1µs per decision
|
||||||
|
- **Minimax AI**: Configurable depth with time limits
|
||||||
|
- **Memory**: Bounded memory usage for tree search
|
||||||
|
|
||||||
|
## Profiling Integration
|
||||||
|
|
||||||
|
- **CPU Profiling**: Integration with perf, VTune
|
||||||
|
- **Memory Profiling**: Valgrind, AddressSanitizer integration
|
||||||
|
- **Cache Analysis**: Cache miss analysis and optimization
|
||||||
|
- **Flame Graphs**: Visual performance analysis
|
||||||
|
|
||||||
|
## Continuous Performance Monitoring
|
||||||
|
|
||||||
|
Benchmarks run automatically to detect performance regressions and track improvements over time.
|
||||||
98
cmake/README.md
Normal file
98
cmake/README.md
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
# CMake Directory (`cmake/`)
|
||||||
|
|
||||||
|
This directory contains CMake configuration files and build system utilities.
|
||||||
|
|
||||||
|
## Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
cmake/
|
||||||
|
├── modules/ # Custom CMake modules
|
||||||
|
│ ├── FindGoogleTest.cmake # Google Test finder
|
||||||
|
│ ├── FindGoogleBenchmark.cmake # Google Benchmark finder
|
||||||
|
│ ├── CompilerWarnings.cmake # Compiler warning configuration
|
||||||
|
│ └── StaticAnalysis.cmake # Static analysis tools
|
||||||
|
├── toolchains/ # Cross-compilation toolchains
|
||||||
|
│ ├── gcc.cmake # GCC toolchain
|
||||||
|
│ ├── clang.cmake # Clang toolchain
|
||||||
|
│ └── mingw.cmake # MinGW cross-compilation
|
||||||
|
├── packaging/ # CPack configuration
|
||||||
|
│ ├── DEB.cmake # Debian package configuration
|
||||||
|
│ ├── RPM.cmake # RPM package configuration
|
||||||
|
│ └── NSIS.cmake # Windows installer configuration
|
||||||
|
└── presets/ # CMake presets
|
||||||
|
├── debug.cmake # Debug build configuration
|
||||||
|
├── release.cmake # Release build configuration
|
||||||
|
└── profile.cmake # Profiling build configuration
|
||||||
|
```
|
||||||
|
|
||||||
|
## Key Features
|
||||||
|
|
||||||
|
### Build Configurations
|
||||||
|
- **Debug**: Full debugging symbols, no optimization, sanitizers enabled
|
||||||
|
- **Release**: Full optimization, minimal debug info, assertions disabled
|
||||||
|
- **RelWithDebInfo**: Optimized with debug symbols for profiling
|
||||||
|
- **Profile**: Special build for performance profiling
|
||||||
|
|
||||||
|
### Compiler Support
|
||||||
|
- **GCC 9+**: Primary compiler with full C++17 support
|
||||||
|
- **Clang 10+**: Alternative compiler with excellent diagnostics
|
||||||
|
- **MSVC 2019+**: Windows support with Visual Studio
|
||||||
|
- **Cross-compilation**: Support for different target architectures
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
- **Automatic Discovery**: Find system-installed dependencies
|
||||||
|
- **FetchContent**: Download and build dependencies automatically
|
||||||
|
- **Conan Integration**: Package manager integration (optional)
|
||||||
|
- **vcpkg Support**: Microsoft's package manager (optional)
|
||||||
|
|
||||||
|
### Static Analysis
|
||||||
|
- **Clang-Tidy**: Static analysis and modernization
|
||||||
|
- **Cppcheck**: Additional static analysis
|
||||||
|
- **Include-what-you-use**: Header dependency analysis
|
||||||
|
- **Sanitizers**: AddressSanitizer, UBSanitizer, ThreadSanitizer
|
||||||
|
|
||||||
|
### Testing Integration
|
||||||
|
- **CTest**: Integrated test runner
|
||||||
|
- **Google Test**: Unit testing framework
|
||||||
|
- **Google Benchmark**: Performance benchmarking
|
||||||
|
- **Coverage**: Code coverage reporting with lcov/gcov
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Basic Build
|
||||||
|
```bash
|
||||||
|
mkdir build && cd build
|
||||||
|
cmake ..
|
||||||
|
cmake --build .
|
||||||
|
```
|
||||||
|
|
||||||
|
### Advanced Configuration
|
||||||
|
```bash
|
||||||
|
# Debug build with sanitizers
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_SANITIZERS=ON ..
|
||||||
|
|
||||||
|
# Release build with static analysis
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_STATIC_ANALYSIS=ON ..
|
||||||
|
|
||||||
|
# Cross-compile for ARM
|
||||||
|
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/arm-linux.cmake ..
|
||||||
|
```
|
||||||
|
|
||||||
|
### CMake Presets (CMake 3.19+)
|
||||||
|
```bash
|
||||||
|
# Use predefined presets
|
||||||
|
cmake --preset debug
|
||||||
|
cmake --build --preset debug
|
||||||
|
|
||||||
|
cmake --preset release
|
||||||
|
cmake --build --preset release
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build Options
|
||||||
|
|
||||||
|
- `BUILD_TESTS`: Build unit tests (default: ON)
|
||||||
|
- `BUILD_BENCHMARKS`: Build performance benchmarks (default: OFF)
|
||||||
|
- `BUILD_EXAMPLES`: Build example programs (default: ON)
|
||||||
|
- `ENABLE_SANITIZERS`: Enable runtime sanitizers (default: OFF in Release)
|
||||||
|
- `ENABLE_STATIC_ANALYSIS`: Run static analysis tools (default: OFF)
|
||||||
|
- `ENABLE_COVERAGE`: Generate code coverage reports (default: OFF)
|
||||||
53
data/README.md
Normal file
53
data/README.md
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# Data Directory (`data/`)
|
||||||
|
|
||||||
|
This directory contains all Pokemon game data files for Generation 1.
|
||||||
|
|
||||||
|
## Planned Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
data/
|
||||||
|
├── pokemon/ # Pokemon species data
|
||||||
|
│ ├── species.json # Base stats, types, learn sets
|
||||||
|
│ └── sprites/ # Pokemon sprite images (optional)
|
||||||
|
├── moves/ # Move definitions
|
||||||
|
│ ├── moves.json # Move data (power, accuracy, PP, etc.)
|
||||||
|
│ └── effects.json # Special move effects
|
||||||
|
├── types/ # Type system data
|
||||||
|
│ └── effectiveness.json # Type matchup chart
|
||||||
|
├── items/ # Items and held items (if implemented)
|
||||||
|
│ └── items.json # Item effects and properties
|
||||||
|
├── mechanics/ # Game mechanics data
|
||||||
|
│ ├── formulas.json # Damage calculation formulas
|
||||||
|
│ └── constants.json # Game constants (crit ratios, etc.)
|
||||||
|
└── validation/ # Data validation schemas
|
||||||
|
├── pokemon.schema.json
|
||||||
|
├── moves.schema.json
|
||||||
|
└── types.schema.json
|
||||||
|
```
|
||||||
|
|
||||||
|
## Data Format
|
||||||
|
|
||||||
|
All data files use JSON format for:
|
||||||
|
- **Human Readability**: Easy to edit and review
|
||||||
|
- **Validation**: JSON schema validation support
|
||||||
|
- **Tooling**: Python scripts can easily process JSON
|
||||||
|
- **Version Control**: Clear diffs for changes
|
||||||
|
|
||||||
|
## Generation 1 Scope
|
||||||
|
|
||||||
|
This directory focuses exclusively on Generation 1 data:
|
||||||
|
- 151 Pokemon species (Bulbasaur through Mew)
|
||||||
|
- Original 165 moves
|
||||||
|
- 15 types (no Dark/Steel/Fairy)
|
||||||
|
- Original battle mechanics and formulas
|
||||||
|
|
||||||
|
## Data Sources
|
||||||
|
|
||||||
|
Data should be sourced from authoritative references:
|
||||||
|
- Bulbapedia for move and Pokemon data
|
||||||
|
- Smogon for competitive mechanics
|
||||||
|
- Original game ROM analysis for accurate formulas
|
||||||
|
|
||||||
|
## Validation
|
||||||
|
|
||||||
|
Python tools in `tools/data/` will validate all data files against schemas to ensure consistency and correctness.
|
||||||
120
docs/README.md
Normal file
120
docs/README.md
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
# Documentation Directory (`docs/`)
|
||||||
|
|
||||||
|
This directory contains project documentation, API references, and development guides.
|
||||||
|
|
||||||
|
## Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
docs/
|
||||||
|
├── api/ # API documentation
|
||||||
|
│ ├── core/ # Core system API docs
|
||||||
|
│ ├── data/ # Data management API
|
||||||
|
│ ├── ai/ # AI system API
|
||||||
|
│ └── utils/ # Utility API docs
|
||||||
|
├── guides/ # Development and usage guides
|
||||||
|
│ ├── getting_started.md # Quick start guide
|
||||||
|
│ ├── building.md # Build instructions
|
||||||
|
│ ├── contributing.md # Contribution guidelines
|
||||||
|
│ ├── architecture.md # System architecture
|
||||||
|
│ └── performance.md # Performance optimization guide
|
||||||
|
├── design/ # Design documents
|
||||||
|
│ ├── battle_system.md # Battle system design
|
||||||
|
│ ├── data_formats.md # Data format specifications
|
||||||
|
│ ├── ai_framework.md # AI system design
|
||||||
|
│ └── memory_layout.md # Memory optimization design
|
||||||
|
├── examples/ # Code examples and tutorials
|
||||||
|
│ ├── basic_battle.md # Simple battle example
|
||||||
|
│ ├── custom_ai.md # Creating custom AI
|
||||||
|
│ ├── data_loading.md # Loading custom data
|
||||||
|
│ └── benchmarking.md # Performance measurement
|
||||||
|
├── reference/ # Reference materials
|
||||||
|
│ ├── gen1_mechanics.md # Generation 1 battle mechanics
|
||||||
|
│ ├── type_chart.md # Type effectiveness reference
|
||||||
|
│ ├── move_list.md # Complete move list
|
||||||
|
│ └── pokemon_list.md # Complete Pokemon list
|
||||||
|
├── assets/ # Documentation assets
|
||||||
|
│ ├── images/ # Diagrams and screenshots
|
||||||
|
│ ├── diagrams/ # Architecture diagrams
|
||||||
|
│ └── data/ # Sample data files
|
||||||
|
├── conf.py # Sphinx configuration
|
||||||
|
├── index.rst # Main documentation index
|
||||||
|
├── Makefile # Documentation build system
|
||||||
|
└── requirements.txt # Documentation dependencies
|
||||||
|
```
|
||||||
|
|
||||||
|
## Documentation Tools
|
||||||
|
|
||||||
|
### Sphinx
|
||||||
|
- **Primary Tool**: Sphinx for comprehensive documentation
|
||||||
|
- **Theme**: Read the Docs theme for professional appearance
|
||||||
|
- **Extensions**: Auto-API generation, math support, code highlighting
|
||||||
|
- **Output Formats**: HTML, PDF, ePub
|
||||||
|
|
||||||
|
### Doxygen
|
||||||
|
- **API Documentation**: Automatic C++ API documentation
|
||||||
|
- **Integration**: Breathe extension for Sphinx integration
|
||||||
|
- **Comments**: Extract documentation from code comments
|
||||||
|
- **Diagrams**: Class and call graphs
|
||||||
|
|
||||||
|
### PlantUML
|
||||||
|
- **Diagrams**: System architecture and sequence diagrams
|
||||||
|
- **Integration**: Embedded in Sphinx documentation
|
||||||
|
- **Version Control**: Text-based diagrams for easy diffing
|
||||||
|
|
||||||
|
## Key Documents
|
||||||
|
|
||||||
|
### Getting Started
|
||||||
|
- Installation and setup instructions
|
||||||
|
- First battle simulation example
|
||||||
|
- Basic API usage patterns
|
||||||
|
- Common troubleshooting
|
||||||
|
|
||||||
|
### Architecture Guide
|
||||||
|
- System overview and component relationships
|
||||||
|
- Data flow and processing pipeline
|
||||||
|
- Performance considerations
|
||||||
|
- Extension points for customization
|
||||||
|
|
||||||
|
### API Reference
|
||||||
|
- Complete C++ API documentation
|
||||||
|
- Usage examples for each component
|
||||||
|
- Performance characteristics
|
||||||
|
- Thread safety guarantees
|
||||||
|
|
||||||
|
### Design Documents
|
||||||
|
- Detailed system design rationale
|
||||||
|
- Alternative approaches considered
|
||||||
|
- Future enhancement plans
|
||||||
|
- Technical debt and limitations
|
||||||
|
|
||||||
|
## Building Documentation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install dependencies
|
||||||
|
pip install -r docs/requirements.txt
|
||||||
|
|
||||||
|
# Build HTML documentation
|
||||||
|
cd docs
|
||||||
|
make html
|
||||||
|
|
||||||
|
# Build PDF documentation
|
||||||
|
make latexpdf
|
||||||
|
|
||||||
|
# Auto-rebuild on changes
|
||||||
|
sphinx-autobuild . _build/html
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contributing to Documentation
|
||||||
|
|
||||||
|
- **Markdown**: Use Markdown for guides and design docs
|
||||||
|
- **reStructuredText**: Use RST for Sphinx integration
|
||||||
|
- **Code Examples**: Include working, tested code examples
|
||||||
|
- **Diagrams**: Use PlantUML for system diagrams
|
||||||
|
- **Screenshots**: Include relevant UI screenshots
|
||||||
|
|
||||||
|
## Documentation Standards
|
||||||
|
|
||||||
|
- **Clarity**: Write for developers unfamiliar with the codebase
|
||||||
|
- **Examples**: Include practical, runnable examples
|
||||||
|
- **Updates**: Keep documentation synchronized with code changes
|
||||||
|
- **Review**: All documentation changes should be reviewed
|
||||||
127
examples/README.md
Normal file
127
examples/README.md
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
# Examples Directory (`examples/`)
|
||||||
|
|
||||||
|
This directory contains example programs and tutorials demonstrating how to use the Pokemon battle simulator.
|
||||||
|
|
||||||
|
## Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
examples/
|
||||||
|
├── basic/ # Basic usage examples
|
||||||
|
│ ├── hello_battle.cpp # Simplest possible battle
|
||||||
|
│ ├── pokemon_creation.cpp # Creating and configuring Pokemon
|
||||||
|
│ ├── move_usage.cpp # Using moves and calculating damage
|
||||||
|
│ └── type_effectiveness.cpp # Type matchup examples
|
||||||
|
├── intermediate/ # More complex examples
|
||||||
|
│ ├── tournament.cpp # Tournament simulation
|
||||||
|
│ ├── ai_comparison.cpp # Comparing different AI strategies
|
||||||
|
│ ├── custom_pokemon.cpp # Loading custom Pokemon data
|
||||||
|
│ └── battle_analytics.cpp # Analyzing battle statistics
|
||||||
|
├── advanced/ # Advanced usage patterns
|
||||||
|
│ ├── custom_ai.cpp # Implementing custom AI
|
||||||
|
│ ├── parallel_battles.cpp # Multi-threaded battle simulation
|
||||||
|
│ ├── memory_optimization.cpp # Memory-efficient patterns
|
||||||
|
│ └── performance_tuning.cpp # Performance optimization
|
||||||
|
├── data/ # Example data files
|
||||||
|
│ ├── sample_pokemon.json # Sample Pokemon definitions
|
||||||
|
│ ├── custom_moves.json # Custom move examples
|
||||||
|
│ └── test_scenarios.json # Battle test scenarios
|
||||||
|
├── python/ # Python integration examples
|
||||||
|
│ ├── wrapper_usage.py # Using Python bindings
|
||||||
|
│ ├── data_analysis.py # Battle result analysis
|
||||||
|
│ └── visualization.py # Battle visualization
|
||||||
|
└── CMakeLists.txt # Build configuration for examples
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example Categories
|
||||||
|
|
||||||
|
### Basic Examples
|
||||||
|
Perfect for developers new to the library:
|
||||||
|
- **hello_battle.cpp**: Minimal battle between two Pokemon
|
||||||
|
- **pokemon_creation.cpp**: Different ways to create Pokemon instances
|
||||||
|
- **move_usage.cpp**: How moves work and damage calculation
|
||||||
|
- **type_effectiveness.cpp**: Understanding the type system
|
||||||
|
|
||||||
|
### Intermediate Examples
|
||||||
|
For developers comfortable with the basics:
|
||||||
|
- **tournament.cpp**: Simulate a complete tournament bracket
|
||||||
|
- **ai_comparison.cpp**: Compare performance of different AI strategies
|
||||||
|
- **custom_pokemon.cpp**: Load and use custom Pokemon data
|
||||||
|
- **battle_analytics.cpp**: Collect and analyze battle statistics
|
||||||
|
|
||||||
|
### Advanced Examples
|
||||||
|
For experienced users and contributors:
|
||||||
|
- **custom_ai.cpp**: Implement sophisticated AI strategies
|
||||||
|
- **parallel_battles.cpp**: Optimize performance with multithreading
|
||||||
|
- **memory_optimization.cpp**: Minimize memory usage patterns
|
||||||
|
- **performance_tuning.cpp**: Squeeze maximum performance
|
||||||
|
|
||||||
|
## Building Examples
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build all examples
|
||||||
|
mkdir build && cd build
|
||||||
|
cmake -DBUILD_EXAMPLES=ON ..
|
||||||
|
make
|
||||||
|
|
||||||
|
# Run a specific example
|
||||||
|
./examples/basic/hello_battle
|
||||||
|
|
||||||
|
# Build only specific examples
|
||||||
|
make hello_battle tournament
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example Template
|
||||||
|
|
||||||
|
Each example follows this structure:
|
||||||
|
```cpp
|
||||||
|
/**
|
||||||
|
* @file example_name.cpp
|
||||||
|
* @brief Brief description of what this example demonstrates
|
||||||
|
*
|
||||||
|
* Detailed explanation of the concepts covered, expected output,
|
||||||
|
* and any prerequisites or setup required.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <pokemon_sim/pokemon_sim.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
// Clear, commented code demonstrating the concept
|
||||||
|
// with realistic usage patterns
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Data Files
|
||||||
|
|
||||||
|
The `data/` subdirectory contains:
|
||||||
|
- **Minimal datasets** for quick examples
|
||||||
|
- **Complete scenarios** for comprehensive demonstrations
|
||||||
|
- **Custom data examples** showing data format flexibility
|
||||||
|
- **Test cases** that can be used for validation
|
||||||
|
|
||||||
|
## Python Integration
|
||||||
|
|
||||||
|
Python examples demonstrate:
|
||||||
|
- **C++ binding usage** with pybind11
|
||||||
|
- **Data analysis** of battle results using pandas
|
||||||
|
- **Visualization** of battle statistics and AI performance
|
||||||
|
- **Integration** with machine learning libraries
|
||||||
|
|
||||||
|
## Running Examples
|
||||||
|
|
||||||
|
Each example is self-contained and includes:
|
||||||
|
- **Clear output** explaining what's happening
|
||||||
|
- **Error handling** for educational purposes
|
||||||
|
- **Performance metrics** where relevant
|
||||||
|
- **Cleanup code** demonstrating proper resource management
|
||||||
|
|
||||||
|
## Contributing Examples
|
||||||
|
|
||||||
|
When adding new examples:
|
||||||
|
- **Focus on one concept** per example
|
||||||
|
- **Include comprehensive comments** explaining the code
|
||||||
|
- **Provide expected output** in comments or separate files
|
||||||
|
- **Test thoroughly** to ensure examples work correctly
|
||||||
|
- **Keep dependencies minimal** to reduce complexity
|
||||||
41
include/README.md
Normal file
41
include/README.md
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Include Directory (`include/`)
|
||||||
|
|
||||||
|
This directory contains all C++ header files (.h/.hpp) for the Pokemon battle simulator.
|
||||||
|
|
||||||
|
## Planned Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
include/
|
||||||
|
├── pokemon_sim/ # Main namespace headers
|
||||||
|
│ ├── core/ # Core battle system headers
|
||||||
|
│ │ ├── battle.h # Battle class and enums
|
||||||
|
│ │ ├── pokemon.h # Pokemon class definition
|
||||||
|
│ │ ├── move.h # Move system headers
|
||||||
|
│ │ ├── type.h # Type system and effectiveness
|
||||||
|
│ │ └── status.h # Status effects
|
||||||
|
│ ├── data/ # Data management headers
|
||||||
|
│ │ ├── pokemon_data.h # Pokemon species data
|
||||||
|
│ │ ├── move_data.h # Move definitions
|
||||||
|
│ │ └── loader.h # Data loading interface
|
||||||
|
│ ├── ai/ # AI system headers
|
||||||
|
│ │ ├── ai_base.h # Base AI interface
|
||||||
|
│ │ ├── random_ai.h # Random AI strategy
|
||||||
|
│ │ └── minimax_ai.h # Minimax AI strategy
|
||||||
|
│ ├── utils/ # Utility headers
|
||||||
|
│ │ ├── random.h # Random utilities
|
||||||
|
│ │ ├── stats.h # Stat calculation helpers
|
||||||
|
│ │ └── constants.h # Game constants
|
||||||
|
│ └── pokemon_sim.h # Main include file
|
||||||
|
```
|
||||||
|
|
||||||
|
## Header Guidelines
|
||||||
|
|
||||||
|
- **Include Guards**: Use `#pragma once` for all headers
|
||||||
|
- **Forward Declarations**: Minimize #include dependencies
|
||||||
|
- **Const Correctness**: Mark methods const where appropriate
|
||||||
|
- **Documentation**: Doxygen-style comments for public APIs
|
||||||
|
- **Namespace**: All code in `pokemon_sim` namespace
|
||||||
|
|
||||||
|
## Public API
|
||||||
|
|
||||||
|
The main `pokemon_sim.h` header provides a clean public interface for library users, hiding implementation details while exposing necessary functionality for battle simulation.
|
||||||
38
src/README.md
Normal file
38
src/README.md
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# Source Directory (`src/`)
|
||||||
|
|
||||||
|
This directory contains all C++ source files (.cpp) for the Pokemon battle simulator.
|
||||||
|
|
||||||
|
## Planned Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
src/
|
||||||
|
├── core/ # Core battle engine
|
||||||
|
│ ├── battle.cpp # Main battle logic
|
||||||
|
│ ├── pokemon.cpp # Pokemon class implementation
|
||||||
|
│ ├── move.cpp # Move system
|
||||||
|
│ └── type.cpp # Type effectiveness
|
||||||
|
├── data/ # Data loading and management
|
||||||
|
│ ├── loader.cpp # Data file loading
|
||||||
|
│ └── validator.cpp # Data validation
|
||||||
|
├── ai/ # AI battle strategies
|
||||||
|
│ ├── random_ai.cpp # Random move selection
|
||||||
|
│ └── minimax_ai.cpp # Minimax algorithm
|
||||||
|
├── utils/ # Utility functions
|
||||||
|
│ ├── random.cpp # Random number generation
|
||||||
|
│ └── stats.cpp # Stat calculations
|
||||||
|
└── main.cpp # Entry point (if building executable)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Design Principles
|
||||||
|
|
||||||
|
- **Performance First**: Optimized for speed and memory efficiency
|
||||||
|
- **Modular Design**: Clear separation of concerns
|
||||||
|
- **Data-Driven**: Pokemon data loaded from external files
|
||||||
|
- **Testable**: Each component designed for unit testing
|
||||||
|
|
||||||
|
## Key Components
|
||||||
|
|
||||||
|
- **Battle Engine**: Core simulation logic
|
||||||
|
- **Pokemon System**: Stats, types, moves, status effects
|
||||||
|
- **AI Framework**: Pluggable AI strategies
|
||||||
|
- **Data Management**: Efficient loading and caching
|
||||||
70
tests/README.md
Normal file
70
tests/README.md
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
# Tests Directory (`tests/`)
|
||||||
|
|
||||||
|
This directory contains all unit tests, integration tests, and test utilities for the Pokemon battle simulator.
|
||||||
|
|
||||||
|
## Planned Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
tests/
|
||||||
|
├── unit/ # Unit tests for individual components
|
||||||
|
│ ├── core/ # Core system tests
|
||||||
|
│ │ ├── test_pokemon.cpp
|
||||||
|
│ │ ├── test_battle.cpp
|
||||||
|
│ │ ├── test_move.cpp
|
||||||
|
│ │ └── test_type.cpp
|
||||||
|
│ ├── data/ # Data loading tests
|
||||||
|
│ │ ├── test_loader.cpp
|
||||||
|
│ │ └── test_validator.cpp
|
||||||
|
│ ├── ai/ # AI system tests
|
||||||
|
│ │ ├── test_random_ai.cpp
|
||||||
|
│ │ └── test_minimax_ai.cpp
|
||||||
|
│ └── utils/ # Utility tests
|
||||||
|
│ ├── test_random.cpp
|
||||||
|
│ └── test_stats.cpp
|
||||||
|
├── integration/ # Integration tests
|
||||||
|
│ ├── test_full_battle.cpp
|
||||||
|
│ ├── test_ai_battles.cpp
|
||||||
|
│ └── test_data_loading.cpp
|
||||||
|
├── fixtures/ # Test data and fixtures
|
||||||
|
│ ├── sample_pokemon.json
|
||||||
|
│ ├── sample_moves.json
|
||||||
|
│ └── test_battles.json
|
||||||
|
├── helpers/ # Test helper utilities
|
||||||
|
│ ├── test_utils.h
|
||||||
|
│ ├── mock_pokemon.h
|
||||||
|
│ └── battle_builder.h
|
||||||
|
└── CMakeLists.txt # Test build configuration
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing Framework
|
||||||
|
|
||||||
|
- **Google Test (gtest)**: Primary testing framework
|
||||||
|
- **Google Mock (gmock)**: For mocking dependencies
|
||||||
|
- **Test Coverage**: Aim for >90% code coverage
|
||||||
|
- **Continuous Integration**: Tests run on every commit
|
||||||
|
|
||||||
|
## Test Categories
|
||||||
|
|
||||||
|
### Unit Tests
|
||||||
|
- Test individual classes and functions in isolation
|
||||||
|
- Fast execution (< 1ms per test)
|
||||||
|
- Mock external dependencies
|
||||||
|
- Focus on edge cases and error conditions
|
||||||
|
|
||||||
|
### Integration Tests
|
||||||
|
- Test component interactions
|
||||||
|
- Use real data files
|
||||||
|
- Validate complete battle flows
|
||||||
|
- Performance regression testing
|
||||||
|
|
||||||
|
### Property-Based Testing
|
||||||
|
- Random battle scenarios
|
||||||
|
- Invariant checking (HP never negative, etc.)
|
||||||
|
- Stress testing with large numbers of battles
|
||||||
|
|
||||||
|
## Test Data
|
||||||
|
|
||||||
|
The `fixtures/` directory contains minimal, controlled test data separate from the main game data, ensuring tests are:
|
||||||
|
- **Deterministic**: Same results every run
|
||||||
|
- **Fast**: Minimal data loading overhead
|
||||||
|
- **Isolated**: Independent of main data changes
|
||||||
96
tools/README.md
Normal file
96
tools/README.md
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
# Tools Directory (`tools/`)
|
||||||
|
|
||||||
|
This directory contains Python scripts and utilities for development, data processing, and project maintenance.
|
||||||
|
|
||||||
|
## Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
tools/
|
||||||
|
├── data/ # Data processing and validation
|
||||||
|
│ ├── __init__.py
|
||||||
|
│ ├── scraper.py # Web scraping for Pokemon data
|
||||||
|
│ ├── validator.py # JSON schema validation
|
||||||
|
│ ├── converter.py # Data format conversion
|
||||||
|
│ └── generator.py # Code generation from data
|
||||||
|
├── build/ # Build and deployment tools
|
||||||
|
│ ├── __init__.py
|
||||||
|
│ ├── configure.py # Build configuration
|
||||||
|
│ ├── package.py # Packaging and distribution
|
||||||
|
│ └── release.py # Release automation
|
||||||
|
├── analysis/ # Performance and code analysis
|
||||||
|
│ ├── __init__.py
|
||||||
|
│ ├── profiler.py # Performance analysis
|
||||||
|
│ ├── coverage.py # Code coverage reporting
|
||||||
|
│ └── complexity.py # Code complexity metrics
|
||||||
|
├── testing/ # Test utilities and generators
|
||||||
|
│ ├── __init__.py
|
||||||
|
│ ├── test_generator.py # Generate test cases
|
||||||
|
│ ├── battle_runner.py # Run battle scenarios
|
||||||
|
│ └── fuzzer.py # Fuzz testing utilities
|
||||||
|
├── docs/ # Documentation generation
|
||||||
|
│ ├── __init__.py
|
||||||
|
│ ├── api_docs.py # API documentation generator
|
||||||
|
│ └── readme_gen.py # README generation
|
||||||
|
├── requirements.txt # Python dependencies
|
||||||
|
├── setup.py # Tool installation script
|
||||||
|
└── common/ # Shared utilities
|
||||||
|
├── __init__.py
|
||||||
|
├── config.py # Configuration management
|
||||||
|
├── logging.py # Logging utilities
|
||||||
|
└── utils.py # Common helper functions
|
||||||
|
```
|
||||||
|
|
||||||
|
## Key Tools
|
||||||
|
|
||||||
|
### Data Processing (`data/`)
|
||||||
|
- **scraper.py**: Scrape Pokemon data from online sources
|
||||||
|
- **validator.py**: Validate JSON data against schemas
|
||||||
|
- **converter.py**: Convert between data formats
|
||||||
|
- **generator.py**: Generate C++ code from data files
|
||||||
|
|
||||||
|
### Build Tools (`build/`)
|
||||||
|
- **configure.py**: Configure build environment and dependencies
|
||||||
|
- **package.py**: Create distribution packages
|
||||||
|
- **release.py**: Automate release process
|
||||||
|
|
||||||
|
### Analysis Tools (`analysis/`)
|
||||||
|
- **profiler.py**: Analyze benchmark results and generate reports
|
||||||
|
- **coverage.py**: Generate code coverage reports
|
||||||
|
- **complexity.py**: Measure code complexity and maintainability
|
||||||
|
|
||||||
|
### Testing Tools (`testing/`)
|
||||||
|
- **test_generator.py**: Generate comprehensive test cases
|
||||||
|
- **battle_runner.py**: Run and analyze battle scenarios
|
||||||
|
- **fuzzer.py**: Fuzz testing for robustness
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd tools
|
||||||
|
pip install -r requirements.txt
|
||||||
|
pip install -e . # Install tools package in development mode
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage Examples
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Validate all data files
|
||||||
|
python -m tools.data.validator
|
||||||
|
|
||||||
|
# Generate C++ headers from JSON data
|
||||||
|
python -m tools.data.generator --output ../include/pokemon_sim/data/
|
||||||
|
|
||||||
|
# Run performance analysis
|
||||||
|
python -m tools.analysis.profiler --benchmark-results ../benchmarks/results/
|
||||||
|
|
||||||
|
# Generate test battles
|
||||||
|
python -m tools.testing.battle_runner --count 1000 --output test_battles.json
|
||||||
|
```
|
||||||
|
|
||||||
|
## Development Guidelines
|
||||||
|
|
||||||
|
- **Python 3.8+**: Minimum Python version
|
||||||
|
- **Type Hints**: Use type annotations for all functions
|
||||||
|
- **Documentation**: Docstrings for all public functions
|
||||||
|
- **Error Handling**: Robust error handling and logging
|
||||||
|
- **Testing**: Unit tests for all tools
|
||||||
17
tools/__init__.py
Normal file
17
tools/__init__.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
"""
|
||||||
|
Pokemon Battle Simulator - Development Tools
|
||||||
|
|
||||||
|
This package contains Python tools and utilities for developing,
|
||||||
|
testing, and maintaining the Pokemon battle simulator.
|
||||||
|
|
||||||
|
Modules:
|
||||||
|
data: Data processing and validation tools
|
||||||
|
build: Build and deployment utilities
|
||||||
|
analysis: Performance and code analysis tools
|
||||||
|
testing: Test generation and execution utilities
|
||||||
|
docs: Documentation generation tools
|
||||||
|
common: Shared utilities and configuration
|
||||||
|
"""
|
||||||
|
|
||||||
|
__version__ = "0.1.0"
|
||||||
|
__author__ = "Pokemon Sim Team"
|
||||||
0
tools/analysis/__init__.py
Normal file
0
tools/analysis/__init__.py
Normal file
0
tools/common/__init__.py
Normal file
0
tools/common/__init__.py
Normal file
0
tools/data/__init__.py
Normal file
0
tools/data/__init__.py
Normal file
0
tools/docs/__init__.py
Normal file
0
tools/docs/__init__.py
Normal file
36
tools/requirements.txt
Normal file
36
tools/requirements.txt
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# Core dependencies
|
||||||
|
requests>=2.28.0 # HTTP requests for data scraping
|
||||||
|
beautifulsoup4>=4.11.0 # HTML parsing for web scraping
|
||||||
|
lxml>=4.9.0 # XML/HTML parser
|
||||||
|
|
||||||
|
# Data processing
|
||||||
|
pandas>=1.5.0 # Data manipulation and analysis
|
||||||
|
numpy>=1.23.0 # Numerical computing
|
||||||
|
jsonschema>=4.17.0 # JSON schema validation
|
||||||
|
pydantic>=1.10.0 # Data validation and settings
|
||||||
|
|
||||||
|
# Development tools
|
||||||
|
click>=8.1.0 # Command line interface creation
|
||||||
|
rich>=12.6.0 # Rich text and beautiful formatting
|
||||||
|
tqdm>=4.64.0 # Progress bars
|
||||||
|
colorama>=0.4.5 # Cross-platform colored terminal text
|
||||||
|
|
||||||
|
# Code analysis
|
||||||
|
coverage>=6.5.0 # Code coverage measurement
|
||||||
|
radon>=5.1.0 # Code complexity analysis
|
||||||
|
mypy>=0.991 # Static type checking
|
||||||
|
black>=22.10.0 # Code formatting
|
||||||
|
flake8>=5.0.0 # Linting
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
pytest>=7.2.0 # Testing framework
|
||||||
|
pytest-cov>=4.0.0 # Coverage plugin for pytest
|
||||||
|
hypothesis>=6.56.0 # Property-based testing
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
sphinx>=5.3.0 # Documentation generation
|
||||||
|
sphinx-rtd-theme>=1.1.0 # Read the Docs theme
|
||||||
|
|
||||||
|
# Optional: Performance profiling
|
||||||
|
py-spy>=0.3.14 # Sampling profiler
|
||||||
|
memory-profiler>=0.60.0 # Memory usage profiler
|
||||||
0
tools/testing/__init__.py
Normal file
0
tools/testing/__init__.py
Normal file
Reference in New Issue
Block a user