Skip to main content

Research bridge for driving Magic: The Gathering agents from MTG Arena game logs (see DISCLAIMER.md)

Project description

inthearena

A research bridge that drives Magic: The Gathering agents from real MTG Arena game data.

inthearena.mtga parses MTGA's detailed client log (its GRE message stream) into typed (pydantic) game state and decision points, then lets a decision Policy pick from the legal options the client is already handed. The first wired policy is AggroPolicy — a relentless develop-and-attack bot — run read-only over your own game logs ("shadow" mode).

from inthearena.mtga import iter_decisions, AggroPolicy, cards

pol = AggroPolicy()
for d in iter_decisions():            # typed decisions from your local Player.log
    print(d.view.phase, d.kind, "->", pol.decide(d))

cards.card_name(79416)                # -> 'Arcane Signet'  (grpId -> name, from the local card DB)
python -m inthearena.mtga.shadow      # replay your games; print what aggro would do at each decision

⚠️ Read this first

This project reads / can automate a live commercial game client. Read DISCLAIMER.md before using it. In short: automating the MTGA client violates its Terms of Service (and can get an account banned), prior art already exists, and this is shared for research — treat it sensitively, and prefer the read-only mode.

What's here

  • mtga/gre.py — parse Player.log into typed GRE objects; diff-accurate gameplay state; surface decisions.
  • mtga/snapshot.py — the gameplay state as a readable snapshot and as mtg-engine facts.
  • mtga/policy.pyPolicy protocol + AggroPolicy (chooses from MTGA's legal menu; no rules engine needed).
  • mtga/cards.py — resolve grpId → English card name from the client's local SQLite card database.
  • mtga/engine.py — position an mtg.Game at the current board by determinization (visible info fed, hidden zones random-filled); format-aware (Brawl vs Standard → engine variant + commander).
  • mtga/views.pyRecognizedViews (Home, Play menu, Recently played, GamePlay) + where each view's clickable elements sit; navigate.py's Navigator walks Home -> Play menu -> queue all the way into a game.
  • mtga/screen.py — recognize the current view from the latest log scene and/or a pluggable image model.
  • mtga/navigate.py — drive a non-game view INTO a game via a pluggable Actuator (no-op by default; the real pyautogui backend is opt-in, pip install inthearena[act], and ToS-relevant — see DISCLAIMER.md). The cursor glides A→B with a wobbled path + jittered speed, lands at a varied spot within the button, and skips the move if it's already there.
  • mtga/vision.py — locate a button on screen with a small local vision model (MoondreamLocator) so click targets come from the live screen, not coordinate estimates (opt-in, pip install inthearena[vision]).
  • mtga/macos.py — find MTGA's window on whichever monitor it's on (find_mtga_window) and capture just that region, so navigation/vision work on a secondary or Retina display, not only the primary one.
  • mtga/live.py — follow Player.log as it's written (tail -f); LiveState keeps board + view current.
  • mtga/shadow.py — run a policy read-only over a log.

Status

Early research. The read + decide half (log → typed state → policy choice, with card names) works today. Driving the live client to actually play is intentionally not included here — that is the ToS-relevant piece (see the disclaimer).

Install (dev)

pip install -e .          # needs pydantic>=2
PYTHONPATH=src python3 tests/test_mtga.py

Distributed on PyPI as inthearena (placeholder release; the real API lands in a later version). MIT licensed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inthearena-0.1.0.tar.gz (144.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

inthearena-0.1.0-py3-none-any.whl (110.1 kB view details)

Uploaded Python 3

File details

Details for the file inthearena-0.1.0.tar.gz.

File metadata

  • Download URL: inthearena-0.1.0.tar.gz
  • Upload date:
  • Size: 144.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for inthearena-0.1.0.tar.gz
Algorithm Hash digest
SHA256 aee41fae1d1020ece31ff4c04ab3d1c4131ce93dffb4f7c7ff7315695d61a769
MD5 c7577d94e0e683f4f93ca642bf0a46e0
BLAKE2b-256 c6fd126c2a82ca377d14a859f4bf8707f60355d2b35830caf762ee802df1ce3b

See more details on using hashes here.

File details

Details for the file inthearena-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: inthearena-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 110.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for inthearena-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3ec418cb790ae2c423ab65bd8279c69fe1d8120369cdf2f0205701187317f53
MD5 327eb292a27ddc4638d62e831dfea50b
BLAKE2b-256 00053b2f5305501a28814e0c1ab6b78db0806a17eccd416ac44d55e744dc4131

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page