skills/llm/cargo-threshold-state-machine/SKILL.md
Per-agent COLLECT/DEPOSIT state machine driven by cargo thresholds with greedy neighbor selection for resource collection games
npx skillsauth add wenmin-wu/ds-skills llm-cargo-threshold-state-machineInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
In resource collection games and multi-agent simulations, each agent needs a persistent decision mode. A simple two-state machine — COLLECT (gather resources) and DEPOSIT (return to base) — switches based on cargo thresholds. In COLLECT mode, the agent greedily moves toward the richest adjacent cell. In DEPOSIT mode, it navigates toward the nearest base. This baseline outperforms random movement and serves as a foundation for more complex strategies.
ship_states = {}
def agent_step(ship, shipyards, get_dir_fn):
if ship.id not in ship_states:
ship_states[ship.id] = "COLLECT"
if ship.halite < 200:
ship_states[ship.id] = "COLLECT"
if ship.halite > 500:
ship_states[ship.id] = "DEPOSIT"
if ship_states[ship.id] == "COLLECT":
if ship.cell.halite < 100:
neighbors = {
'NORTH': ship.cell.north.halite,
'EAST': ship.cell.east.halite,
'SOUTH': ship.cell.south.halite,
'WEST': ship.cell.west.halite,
}
return max(neighbors, key=neighbors.get)
return None # stay and mine
if ship_states[ship.id] == "DEPOSIT":
return get_dir_fn(ship.position, shipyards[0].position)
data-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF