Phase based strategy cycling

From wenmin-wu/ds-skills · View interactive version

Phase based strategy cycling is an AI agent skill from the GitHub repository wenmin-wu/ds-skills. Divide a game into repeating phases (attack, mine, spawn) with turn-modular gating so the agent cycles between aggressive and economic behavior

How to use this skill

Skill file

Phase-Based Strategy Cycling

Overview

In multi-phase game AI, a single static strategy loses to adaptive play. Dividing the game into repeating cycles — e.g., attack (turns 0-20), mine (20-90), idle/spawn (90-100) within each 100-turn block — lets a heuristic agent alternate between aggression and economy. Each phase has different action priorities and ship allocation rules.

Quick Start

def agent(obs, config):
    board = Board(obs, config)
    me = board.current_player
    turn = board.step
    cycle_pos = turn % 100

    for shipyard in me.shipyards:
        if cycle_pos < 20 and shipyard.ship_count >= 50:
            launch_attack(shipyard, board)
        elif 20 <= cycle_pos < 90 and shipyard.ship_count >= 10 and turn % 7 == 0:
            launch_mining_fleet(shipyard, turn)
        elif me.kore >= board.configuration.spawn_cost * shipyard.max_spawn:
            shipyard.next_action = ShipyardAction.spawn_ships(shipyard.max_spawn)

    return me.next_actions

Workflow

  1. Define cycle length (e.g., 100 turns) and phase boundaries
  2. Attack phase: accumulate ships, launch large fleets at nearest enemy structures
  3. Mining phase: send periodic small fleets on patrol routes, rotate directions
  4. Spawn phase: spend excess resources on ship production for the next cycle
  5. Add early-game override: pure spawning for the first N turns to build up economy
  6. Tune phase boundaries and thresholds via self-play evaluation

Key Decisions

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.