cli-anything-slay-the-spire-ii 是做什麼的?
一個狀態化的命令列介面,用於透過本機 STS2_Bridge 模組控制真實的《殺戮尖塔 2》遊戲。CLI 會讀取正規化的遊戲狀態,並透過本機 HTTP API (localhost:15526) 發送動作指令。
安裝說明
此 CLI 需要在遊戲程序中執行一個橋接模組。CLI 與橋接模組都從同一個儲存庫發布:
https://github.com/HKUDS/CLI-Anything
1. 安裝 CLI
git clone https://github.com/HKUDS/CLI-Anything.git
cd CLI-Anything/slay_the_spire_ii/agent-harness
pip install -e .
2. 建置與安裝橋接模組
橋接模組是一個必須編譯並安裝到遊戲目錄的 .NET 9 插件。完整說明請參考儲存庫的 README,簡要步驟如下:
cd CLI-Anything/slay_the_spire_ii/agent-harness/bridge/plugin
./build.sh
cd ../install
./install_bridge.sh
如果建置腳本無法自動偵測遊戲資料目錄,請明確設定 STS2_GAME_DATA_DIR:
STS2_GAME_DATA_DIR="/path/to/data_sts2" ./build.sh
3. 啟用模組並驗證
透過 Steam 啟動《殺戮尖塔 2》,在模組管理器中啟用 STS2_Bridge 模組,然後驗證連線:
cli-anything-sts2 state
如果回傳 JSON,表示 CLI 與橋接模組已成功連線。
必要條件:
- Python 3.10+
- 已啟用
STS2_Bridge 模組的 Steam 版《殺戮尖塔 2》
.NET 9 SDK(僅用於建置橋接模組)
使用方式
基本指令
cli-anything-sts2 state
cli-anything-sts2
cli-anything-sts2 --help
指令群組
狀態檢查
| 指令 | 說明 |
|---|
state | 包含 decision 欄位的正規化狀態 |
raw-state | 原始橋接 JSON |
主選單
| 指令 | 說明 |
|---|
continue-game | 繼續存檔進度 |
start-game --character IRONCLAD --ascension 0 | 開始新遊戲 |
abandon-game | 放棄當前存檔 |
return-to-main-menu | 從任何畫面返回主選單 |
角色:IRONCLAD、SILENT、DEFECT、NECROBINDER、REGENT
戰鬥
| 指令 | 說明 |
|---|
play-card <index> [--target <enemy_id>] | 從手牌中出牌 |
use-potion <slot> [--target <enemy_id>] | 使用藥水 |
end-turn | 結束當前回合 |
地圖與房間流程
| 指令 | 說明 |
|---|
choose-map <index> | 選擇地圖節點 |
proceed | 離開當前房間 |
獎勵
| 指令 | 說明 |
|---|
claim-reward <index> | 領取戰鬥獎勵 |
pick-card-reward <index> | 選擇卡牌獎勵 |
skip-card-reward | 跳過卡牌獎勵 |
claim-treasure-relic <index> | 領取寶箱遺物 |
select-relic <index> | 選擇遺物 |
skip-relic-selection | 跳過遺物選擇 |
事件與休息處
| 指令 | 說明 |
|---|
event <index> | 選擇事件選項 |
advance-dialogue | 推進純對話事件 |
rest <index> | 選擇營火行動 |
商店
| 指令 | 說明 |
|---|
shop-buy <index> | 從商店購買 |
卡牌/遺物選擇覆疊
| 指令 | 說明 |
|---|
select-card <index> | 在覆疊中選擇卡牌 |
confirm-selection | 確認當前選擇 |
cancel-selection | 取消當前選擇 |
combat-select-card <index> | 在戰鬥覆疊中選擇卡牌 |
combat-confirm-selection | 確認戰鬥卡牌選擇 |
原始動作
| 指令 | 說明 |
|---|
action <name> --kv key=value | 發送原始橋接動作 |
決策狀態
state 指令回傳的 JSON 中包含一個 decision 欄位,用於指示當前的遊戲畫面。請根據此值來決定下一步指令:
| 決策狀態 | 含義 | 常用的後續指令 |
|---|
menu | 主選單 | continue-game, start-game |
combat_play | 戰鬥中,你的回合 | play-card, use-potion, end-turn |
hand_select | 卡牌選擇覆疊 | combat-select-card, combat-confirm-selection |
map_select | 地圖節點選擇 | choose-map |
game_over | 遊戲結束 | return-to-main-menu |
combat_rewards | 戰鬥後獎勵 | claim-reward, proceed |
card_reward | 卡牌獎勵選擇 | pick-card-reward, skip-card-reward |
event_choice | 事件畫面 | event, advance-dialogue |
rest_site | 營火 | rest |
shop | 商店畫面 | shop-buy, proceed |
card_select | 卡牌選擇畫面 | select-card, confirm-selection |
relic_select | 遺物選擇 | select-relic, skip-relic-selection |
treasure | 寶箱房間 | claim-treasure-relic, proceed |
設定
| 選項 | 預設值 | 說明 |
|---|
--base-url | http://localhost:15526 | 橋接 API URL |
--timeout | 10.0 | HTTP 逾時秒數 |
給 AI 代理程式的提示
- 務必先讀取
state 以取得 decision 欄位
- 每次動作後重新讀取狀態——戰鬥中的索引與能量會持續變化
- 檢查回傳碼——0 代表成功,非零值代表錯誤
- 解析 stdout 以取得 JSON 輸出