# ============================================================================= # State of Survival Bot — Playbook # ============================================================================= # Steps are evaluated TOP-to-BOTTOM each loop. The FIRST matching step runs. # Put more specific conditions first, generic fallback last. # # HOW TO ADD NEW BEHAVIOR: # 1. Take a screenshot: python debug_screenshot.py # 2. Crop the target button/icon from the saved image # 3. Save the crop as templates/your_template.png # 4. Add a step below referencing it via "if_template" # ============================================================================= adb_host: "127.0.0.1" adb_port: 5555 loop_delay: 3 # seconds between iterations steps: # ────────────────────────────────────────────────────────── # CLOSE POPUPS # ────────────────────────────────────────────────────────── - name: "Close popup ad (X button top-right)" if_template: "close_ad.png" confidence: 0.75 region: [1440, 0, 1600, 300] then: - action: find_and_click params: template: "close_ad.png" confidence: 0.75 region: [1440, 0, 1600, 300] - action: wait params: { seconds: 2 } - name: "Close generic dialog (X)" if_template: "dialog_close.png" confidence: 0.75 region: [1480, 0, 1600, 100] then: - action: find_and_click params: template: "dialog_close.png" confidence: 0.75 region: [1480, 0, 1600, 100] - action: wait params: { seconds: 1 } - name: "Press BACK to dismiss overlays" if_template: "back_btn.png" confidence: 0.7 region: [0, 0, 100, 150] then: - action: keyevent params: { key: "back" } - action: log params: { message: "Back pressed (dismiss overlay)" } # ────────────────────────────────────────────────────────── # COLLECT / GATHER # ────────────────────────────────────────────────────────── - name: "Collect from finished gathering" if_template: "collect_btn.png" confidence: 0.75 then: - action: find_and_click params: { template: "collect_btn.png" } - action: wait params: { seconds: 2 } - action: tap params: { x: 1300, y: 700 } - action: wait params: { seconds: 2 } - action: tap params: { x: 1553, y: 32 } - action: log params: { message: "Resources collected" } # ────────────────────────────────────────────────────────── # HEAL TROOPS # ────────────────────────────────────────────────────────── - name: "Heal wounded troops" if_template: "heal_btn.png" confidence: 0.75 then: - action: find_and_click params: { template: "heal_btn.png" } - action: wait params: { seconds: 2 } - action: find_and_click params: { template: "heal_all.png", confidence: 0.7 } - action: wait params: { seconds: 2 } - action: tap params: { x: 1553, y: 32 } - action: log params: { message: "Troops healed" } # ────────────────────────────────────────────────────────── # TRAIN TROOPS # ────────────────────────────────────────────────────────── - name: "Train troops" if_template: "train_btn.png" confidence: 0.75 then: - action: find_and_click params: { template: "train_btn.png" } - action: wait params: { seconds: 3 } - action: tap params: { x: 800, y: 750 } - action: wait params: { seconds: 1 } - action: tap params: { x: 1553, y: 32 } - action: log params: { message: "Training queued" } # ────────────────────────────────────────────────────────── # UPGRADE BUILDINGS # ────────────────────────────────────────────────────────── - name: "Find & upgrade building (slot 1)" if_template: "upgrade_arrow.png" confidence: 0.7 region: [50, 200, 200, 600] then: - action: tap params: { x: 63, y: 240 } - action: wait params: { seconds: 2 } - action: find_and_click params: { template: "upgrade_btn.png", confidence: 0.7 } - action: wait params: { seconds: 1 } - action: tap params: { x: 1553, y: 32 } - action: log params: { message: "Building upgrade attempted" } # ────────────────────────────────────────────────────────── # ALLIANCE HELP # ────────────────────────────────────────────────────────── - name: "Send alliance help" if_template: "alliance_help_btn.png" confidence: 0.75 then: - action: find_and_click params: { template: "alliance_help_btn.png" } - action: wait params: { seconds: 1 } - action: click_seq params: coords: [[1149, 614], [1149, 675], [1149, 749]] delay: 0.3 - action: tap params: { x: 46, y: 33 } # back to settlement - action: log params: { message: "Alliance help sent" } # ────────────────────────────────────────────────────────── # RESTART: every 180th iteration (≈9min at 3s delay) # ────────────────────────────────────────────────────────── - name: "Periodic restart (every 180 cycles)" if_counter: 180 then: - action: app params: action: "restart" package: "com.kingsgroup.sos" wait: 15 - action: log params: { message: "Periodic restart" } # ────────────────────────────────────────────────────────── # IDLE FALLBACK # ────────────────────────────────────────────────────────── - name: "Idle — nothing matched" always: true then: - action: wait params: { seconds: 5 }