How vincentzyx/douzero_for_hlddz_fullauto works
Project’s Core Purpose and Type
• It is an automation solution for a popular card game (Happy Dou Di Zhu), integrating AI decision-making through reinforcement learning and supervised learning models.
• It builds upon the original DouZero and its Happy Dou Di Zhu variant, so the architecture reflects components for game screen capture, environment simulation, AI inference (using deep learning models like ResNet), and the user interface.
Main Components
a. User Interface (UI) Layer:
– Files such as MainWindow.py and MainWindow.ui define the visual controls.
– The UI allows manual/automatic toggling; it also outputs key instructions (e.g., auto-start, auto-continue) after capturing the game screen.
b. Game Environment and Screen Capture:
– The project requires capturing game screens for decision making (see debug_screenshot.py).
– Components in the douzero/env folder (e.g., game.py, move_detector.py, move_generator.py) encapsulate logic to detect game state, moves, and interactions with the game’s window.
c. AI Models and Decision Logic:
– Core AI components include BidModel.py, FarmerModel.py, LandlordModel.py. These encapsulate decision-making logic for bidding, playing cards, and doubling.
– The project leverages pretrained deep neural network models (stored in the baselines/resnet and weights directories) with ResNet-based checkpoints.
d. Data and Configuration:
– Configuration files like requirements.txt and data.json, as well as weight pickle files under the weights folder, provide necessary dependencies and pretrained parameters.
– Also include the README and usage documents (使用说明.docx) as supporting documentation.
Relationships and Flow
• The screen capture mechanism (using debug_screenshot.py and integrated window handling) collects game state information.
• This information is sent to the Game Environment modules to interpret the current game setting (cards, moves, etc.).
• The interpreted state then drives the AI Models (bid, farmer, landlord) which load the appropriate weights from the baselines/resnet and weights directories.
• Results (e.g., the decision to bid, call, or double) are fed back and displayed on the UI, and commands are dispatched to interact with the game.
• In parallel, evaluation modules (found under douzero/evaluation) may simulate multiple game scenarios, enhancing and validating the AI’s decisions.
Architectural Patterns and Design Principles
• The design is modular – separating UI, environment detection, and AI decision-making logic for maintainability and ease of testing.
• It follows a loosely coupled pipeline architecture: input (game screen) → processing (environment analysis) → decision (model inference) → output (command issuance).