LogoLogo
  • 🐟An Introduction to Bluetang
  • Features
    • 📔Overview
  • Deepseek Integration
    • 😃What are the benefits?
  • How To Use
    • ℹ️Important Information
    • 🔗Important Links
    • 📖Wiki
      • 💾Installation
        • 💿Linux
        • 🪟Windows
      • 🔃Update
      • 💻Bluetang CLI Tool
      • 👨‍💻Classes
        • GameAgent Class
        • Game Class
        • GameFrame Class
        • InputController Class
      • 🔌Plugins
        • GameAgent Plugin
        • Game Plugin
        • Training a Context Classifier
  • 📑Whitepaper
Powered by GitBook
On this page
  • Core Components
  • Key Concepts
  • Methods
  1. How To Use
  2. Wiki
  3. Classes

Game Class

The Game class represents a generic video game in the Bluetang framework.

Core Components

  • Launch game through GameLauncher

  • Manage game window information

  • Control FrameGrabber instances

  • Feed GameFrames to GameAgent

  • Throttle frame feed speed

  • Expose game-specific API

  • Register and manage game sprites

  • Manage regions of interest

  • Handle OCR presets

Window Information

  • self.window_id: OS-specific window ID

  • self.window_name: Window title

  • self.window_geometry: Window dimensions and position

Game-Specific

  • self.api: GameAPI instance

  • self.sprites: Registered Sprite collection

  • self.screen_regions: Named screen regions

  • self.ocr_presets: OCR configuration presets

Status Flags

  • self.is_launched: Game running status

  • self.is_focused: Window focus status

Key Concepts

Frame Grabbing

When play is called, a FrameGrabber runs in the background as a separate process:

  • Maintains precise capture rate (default: 30 FPS)

  • Stores image data in memory stack

  • Automatically shuts down with main process

Game Frame Limiter

Frame dispatch to game agents is throttled to ensure:

  • Realistic APM (actions per minute)

  • Normalized intervals between actions

  • Natural gameplay feel

Default limit: 2 FPS (120 APM theoretical maximum) Configure in: config/config.plugins.yml

Game API

Game Plugins can include GameAPI subclasses with:

  • Game-specific utilities

  • UI operations

  • Image processing routines

Sprites & Regions

  • Sprites: Auto-registered from files/data/sprites

  • Screen Regions: Define rectangular regions of interest

  • OCR Presets: Configure text recognition settings

Methods

launch

def launch(self, dry_run=False)

Launches the game and runs callbacks.

Cannot be overwritten by plugins

play

def play(self, game_agent_class_name=None, frame_handler=None, **kwargs)

Initializes and runs a game agent with specified frame handler.

Cannot be overwritten by plugins

Callbacks

def before_launch(self)
def after_launch(self)
  • Can be overwritten by plugins

  • after_launch requires super() call

  • Used for custom launch logic

PreviousGameAgent ClassNextGameFrame Class

Last updated 4 months ago

📖
👨‍💻