Skip to content

Add replay event logging and playback system for build order extraction#1

Draft
Copilot wants to merge 5 commits intomasterfrom
copilot/add-replay-upload-logging
Draft

Add replay event logging and playback system for build order extraction#1
Copilot wants to merge 5 commits intomasterfrom
copilot/add-replay-upload-logging

Conversation

Copy link
Copy Markdown

Copilot AI commented Nov 19, 2025

Enables extracting build orders from SC2 replay files and executing them during bot gameplay.

Changes

Core Event System

  • ReplayEvent: Serializable event model with frame timestamp, unit type, position, and event type (BuildingStarted, BuildingCompleted, UnitCreated)
  • EventLogger: Tracks unit/building creation during replay playback, detects new entities via tag comparison, uses BuildingType.GetBuildingSize() for building classification
  • EventPlayer: Executes logged events at correct frames during gameplay, handles resource/tech failures gracefully

Integration

  • GameConnection: Added RunReplayAndLogEvents() for replay analysis mode using SC2 API's RequestStartReplay
  • Controller: Injected EventPlayer into frame loop, processes events in OpenFrame()
  • Program.cs: Two new CLI modes:
    • --replay <path> [player_id] [output] for event extraction
    • --playback <event_log> for build order execution

Serialization

  • JSON format using DataContractJsonSerializer for .NET Framework 4.7.2 compatibility
  • Events stored with frame-level granularity for deterministic playback

Usage

Extract build order from replay:

BotRunner.exe --replay "game.SC2Replay" 1 "zerg_12pool.json"

Execute extracted build order:

BotRunner.exe --playback "zerg_12pool.json"

Event log format:

[
  {
    "Frame": 224,
    "EventType": "BuildingStarted",
    "UnitType": 86,
    "PositionX": 125.5,
    "PositionY": 132.0,
    "PositionZ": 11.98,
    "PlayerId": 1
  }
]
Original prompt

Create an option to upload a replay, run it, log the important events from replay, e.g. a building is constructed at a certain time, and then this log must be able to execute by the bot when the bot plays the game


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits November 19, 2025 23:20
Co-authored-by: dnaumov <150417680+dnaumov@users.noreply.github.com>
Co-authored-by: dnaumov <150417680+dnaumov@users.noreply.github.com>
Co-authored-by: dnaumov <150417680+dnaumov@users.noreply.github.com>
Co-authored-by: dnaumov <150417680+dnaumov@users.noreply.github.com>
Copilot AI changed the title [WIP] Add option to upload and log important replay events Add replay event logging and playback system for build order extraction Nov 19, 2025
Copilot AI requested a review from dnaumov November 19, 2025 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants