SuperAstra README

The project's README from github.com/ScottStevenson/SuperAstra. As one markdown file: README.md.

SUPERASTRA

Change the game.

A SNES-themed desktop companion that lets Astra investigate and alter a running game through natural-language prompts. Built for BizHawk, with an RPG-style interface and live memory tools.

SUPERASTRA desktop interface

The agent can inspect the actual game, find memory structures, write new memory routines or cartridge patches, test the result, and keep what it learns for that exact cartridge version. The same investigation tools are available for an unrecognized game and a previously unseen request.

This v0.3.2 prototype has passed real Snes9x game-behavior tests and automated Lua/protocol checks. The Windows Lua bridge connection has also been confirmed manually. See validation notes for the scope of these checks.

Start playing

You need Windows or Linux, Python 3.10 or newer with Tkinter, a current BizHawk release, your ROM, and an OpenAI API key whose project can use gpt-6-astra.

  1. Extract this entire folder somewhere writable. Keep its files together.
  2. Double-click Start-Windows.cmd, or run python3 run.py on Linux.
  3. In BizHawk, open the ROM. Use its BSNES SNES core. Open Tools → Lua Console, then open LOAD-IN-BIZHAWK.lua from this folder.
  4. Keep emulation running. The companion will show the cartridge name.
  5. Open Settings, enter your API key, and leave the model as gpt-6-astra. Type what you want and click Cast prompt.

This runs alongside the desktop emulator. It is not an iPhone emulator extension and is not a hosted website. The app requires no Python packages beyond the standard library. Linux distributions sometimes package Tkinter separately as python3-tk.

Does it work while I play?

That is the intended workflow. The companion reads the running game, and Lua applies changes between frames. Emulation continues while Astra thinks or researches. A request is not instantaneous: it can require several API calls and observations. Generated ongoing effects execute locally each frame without an API call for each update.

Controlled experiments temporarily run an earlier checkpoint and return to the player's pre-experiment state. They can visibly interrupt play for up to 300 emulated frames per trial. This prototype uses the same emulator for those trials; it does not run a separate invisible emulator in the background.

The live engine behavior has been tested through Snes9x. Native BizHawk and a live Astra request still require an end-to-end desktop test.

Prompts and unfamiliar games

Try the original examples in Super Mario World:

For another game, ask directly for the alteration. Examples of investigation requests include “Find my health and keep it full while I'm playing” or “Figure out how this game stores enemies so we can spawn another one.” These are requests for Astra to investigate, not claims that those behaviors have been tested in every game.

The agent receives:

Context What it can do with it
Live screenshot Identify characters, objects, menus and visible results
Cartridge hash, headers and vectors Identify the exact version and investigate its mapping
Local cartridge index Read or search actual code and data without uploading the whole ROM
CPU registers and disassembly Follow implementation details where the emulator core supports them
WRAM reads and scans Find values, object tables and state flags
Hardware-domain reads Inspect exposed VRAM, OAM, CGRAM, audio RAM and cartridge RAM
Frame observations and controller probes Compare values with what happens during play
Named checkpoints and experiments Test a hypothesis against the same starting state, capture results, then restore the player state
CPU bus write watch See which registers/code are associated with a write, on supporting cores
Persistent game notebook Reuse a working plan, hypotheses, evidence, previous routines and automatically recorded tool results
Optional web research Find disassemblies and memory documentation, then check against the ROM
Searchable source collection Import full text/source files using Add context, then retrieve relevant symbols and numbered lines

The general path works without a recognized game profile. Astra can create a new one-shot routine, an effect that runs each frame, or a guarded patch to code/data in the loaded cartridge. The built-in Mario actions provide optional shortcuts.

“Any game, any prompt” describes the interface and investigation goal, not a guarantee of success. The model still has to discover the right structures and verify its reasoning. An unfamiliar game can take multiple requests or need user observations, source notes or additional reverse engineering. Some requests need new assets, more cartridge space, a coprocessor debugger or a larger game engine rewrite. This version can edit existing loaded cartridge bytes; it cannot expand the ROM, create an exportable ROM patch, synthesize new artwork, or debug every special chip. Astra must identify a missing capability or unknown mechanic and report it honestly. No implementation can guarantee every imaginable prompt.

How an unfamiliar game gains context

  1. Read the screen, ROM identity/header candidates, registers and available domains.
  2. Retrieve relevant saved knowledge, imported sources or primary web documentation.
  3. Build a working model of the required mechanics: game mode, state fields, object lifecycle, initialization code and graphics dependencies as applicable.
  4. Create a checkpoint. Compare a control run with one changed input or candidate alteration. Results include sampled values, WRAM differences and a branch screen.
  5. Apply a successful candidate to the live game, verify it, and retain evidence.

Tool evidence is recorded automatically; hypotheses are kept separate from verified findings. Resume resumes saved work, including after restarting the companion. It refreshes live context and never automatically replays an old mutation. The latest bounded tool transcript and a compact working plan are retained; older tool evidence is searchable. The default is 32 API steps per request, adjustable to 1–256 in settings or with --steps.

Add context accepts multiple UTF-8 source/text files, up to 8 MiB each, 32 files and 32 MiB total per ROM. Astra searches them locally and requests relevant excerpts. Lexical search uses keywords, addresses and symbols. It does not upload an entire imported source collection automatically. Game knowledge displays the retained plan, recent evidence and available sources.

Undo and ongoing effects

Each committed memory mutation gets a full emulator checkpoint. Undo restores the entire game to just before the last mutation, including gameplay since that moment, with the loaded-cartridge byte journal restored as well. Up to eight Undo states and four independent named experiment checkpoints are retained in memory.

Stop effects removes active routines, memory freezes and loaded-cartridge patches. It leaves current WRAM values as they are. Stop thinking prevents the next AI tool operation; it does not undo previous actions. Undo and Stop effects can also be used while Astra is waiting for the API. An in-progress temporary experiment is restored when cancelled. External state/ROM loads supersede the experiment.

Opening another ROM, loading a state externally, or restarting the Lua bridge clears effects and checkpoints. Undo can restore earlier routines and cartridge patches. Your original ROM file is never patched by this app. Cartridge changes are limited to 4096 bytes per operation and 64 KiB of distinct journaled offsets per bridge session; a core must expose writable ROM for these operations.

What gets created on your computer

API keys entered in settings are kept in memory, not written to these files. You can instead set OPENAI_API_KEY; OPENAI_MODEL optionally overrides the model. Prompts, screenshots, requested memory/code windows, notes and selected findings are sent to OpenAI. Full cartridge and RAM dumps are processed locally. Enabling web research also lets Astra send game-related search queries. API usage is billed to the configured OpenAI project; the app shows token counts after a turn.

Terminal use

Run these from the extracted folder:

python run.py --doctor
python run.py --status
python run.py --prompt "Drop a star"
python run.py --prompt "Find the code that updates my health" --no-web
python run.py --prompt "Continue" --steps 64

The explicit Local Mario shortcuts mode needs no API key. It understands a few phrases, including the two original examples, and is useful for checking the emulator connection:

python run.py --local --prompt "Drop a star"
python run.py --local --prompt "Put 5 chucks on the screen"
python run.py --local --prompt "Undo"

The supplied shortcuts accept the unmodified USA SMW SHA-1 and the exact Ice Flower build used for game testing. Other revisions still have the general agent tools. Vanilla sprite slots and level graphics limits still apply: a request for five enemies needs five free slots, and Chucks may have missing or wrong tiles in levels that do not load their graphics.

When loaded-cartridge patches are active, the verified-layout Mario shortcuts are disabled; the general tools remain available to reassess the modified game.

Updating

Stop the Lua bridge and companion, then replace their source files together with this version. Preserve your existing knowledge/ directory to keep discoveries; the older notebook format is read automatically. Restart both components. Do not mix files from different releases. Checkpoints exist only in the emulator session.

If the connection does not respond

Development

See CONTRIBUTING.md for development and release instructions, architecture for extension points, and validation for exactly what was tested.

Unit/integration tests require the optional Lua test runtime:

python -m pip install -r requirements-dev.txt
python -m unittest discover -s tests -v

No emulator binary or commercial ROM is included. The small json.lua dependency is included under its MIT license in emulator/json-LICENSE.txt. This project's original source is MIT-licensed; see LICENSE. The Spellbook logo is a separate brand asset; see asset credits.

Primary references

SuperAstra (ScottStevenson/SuperAstra)

Searching Database…

这是什么?SuperAstra 是一个桌面伴侣程序,让名为 Astra 的 AI 智能体通过自然语言提示,调查并修改 BizHawk 里正在运行的 SNES 游戏,实时写入新的内存例程或卡带补丁。
它本身是模拟器,还是配合模拟器运行?它不是模拟器——而是一个独立的桌面应用,通过 Lua 桥接连接到 BizHawk(也在 Snes9x 上测试过);它明确不是 iPhone 模拟器扩展,也不是托管网站。
怎么让它和 BizHawk 一起跑起来?解压文件夹,双击 Start-Windows.cmd(或在 Linux 上运行 `python3 run.py`),用 BizHawk 的 BSNES 核心加载你的 ROM,打开 Tools -> Lua Console 并运行文件夹里的 LOAD-IN-BIZHAWK.lua,然后在 Settings 中输入你的 OpenAI API 密钥并输入提示词。
使用之前我需要准备什么?Windows 或 Linux、带 Tkinter 的 Python 3.10+、当前版本的 BizHawk、你自己的 ROM,以及一个其项目能访问 gpt-6-astra 模型的 OpenAI API 密钥。
“任何游戏、任何提示”真的开箱即用吗?不保证——Astra 需要自己发现正确的内存结构,所以面对不熟悉的游戏可能需要多次请求、查看源码注释或手动逆向;而且这个版本无法扩展 ROM、生成可导出的补丁、合成新美术,也无法调试每一颗协处理器芯片。
必须用 Windows 吗,Linux 上也能运行吗?两者都支持——你只需要带 Tkinter 的 Python 3.10+,在某些 Linux 发行版上它是一个单独的 python3-tk 软件包;macOS 未被提及。
我的游戏和提示数据会被发到哪里?提示词、截图、请求查看的内存/代码窗口、笔记以及选定的发现会发送给 OpenAI 处理,但完整的卡带镜像和 RAM 转储留在你的电脑上,只在本地建立索引。
整个项目都是 MIT 许可证吗?源代码采用 MIT 许可证,但 Spellbook 标志是单独的品牌资产,不在该许可证覆盖范围内。
gpt-6-astra 是什么?它是这个应用围绕构建的特定 OpenAI 模型;你的 API 密钥所属项目必须能访问它,Astra 的全部推理、调查和工具调用都由它驱动。
Astra 做的修改能撤销吗?可以——每一次提交的内存修改都会生成完整的模拟器检查点,Undo 能恢复整个游戏(包括那一刻之后的游戏进程),内存中最多保留八个撤销状态。
没有 OpenAI API 密钥也能试用吗?可以,内置的 Local Mario 快捷指令模式能听懂几个针对 Super Mario World 的预设短语,不需要 API 密钥,主要用于检查模拟器连接。
SuperAstra 会在我的电脑上创建哪些文件?它会创建一个用于实时连接和截图的 ipc/ 文件夹、一个存放每张卡带的发现成果、例程和调查记录的 knowledge/ 文件夹,以及一个可选的 profiles/ 文件夹(存放已识别游戏的精确哈希字段映射)。
Size
1 MB
Stars
291
Updated
CommitSep 06
Age
1mo
Commits · 90 Days