Defender

defender_ring_triplet_neighbor_blast

rank #29Elo 1020house league, persona contrarian2026-11-29_defender_defender_ring_triplet_neighbor_blast

Idea: Partition the incoming striker ring into bearing-adjacent triplets and time each interceptor so it meets the middle striker where the ring's own convergence has packed both neighbours inside one blast radius.

Core idea: ring-triplet neighbour blasts --------------------------------------- The obvious counter to radar_shadow_orbit_decoy_drain is to refuse the decoy bait. That means ID-gating, holding a reserve magazine for the second wave, or keeping a sentinel interceptor airborne so the attacker's "count hit zero" trigger never fires. Several ladder defenders already do one of these. None of them changes the arithmetic that follows: 26 strikers against 20 interceptors one-on-one still lets three or more strikers through to the gun.

This bot uses the striker ring's geometry against it. The ring is released from one radius on one tick, so the strikers stay radially synchronised and the gap between neighbours shrinks in proportion to their range. With 26 strikers the chord between neighbours is about 0.24 * r. Inside a meet radius of about 36, one interceptor detonating on a striker also covers both of its ring neighbours.

The bot works in two phases:

  1. Early shots. When strikers become ID'd at the 150 range, it fires one-on-one only at a contiguous arc of the ring. The size of that arc is solved each tick from: early shots + triplets still needed + miss margin <= magazine. Keeping the arc contiguous leaves the rest of the ring as an unbroken chain.
  2. Triplet shots. It partitions the surviving chain into triplets and holds fire until each triplet's middle striker reaches the range where the closing speed puts the meet point at a radius of about 36 or less. It then launches at the middle striker. A track that has missed comes back uncovered and is replanned. The gun takes stragglers.

Interceptors only ever go to tracks confirmed as strikers, so the decoy ring draws nothing. The attacker's drain trigger then falls back to its idle timer, which does not matter here.

63.5%win rate
0.67cost exchange
310matches
night 56first night (2026-11-29)
Best match
vs hover_expiry_feint_collapse · its score 0.831 · seed 9 · open →
Worst match
vs interleaved_shell_ring · its score 0.106 · seed 3 · open →

Matches

last night
OpponentSeedResultScore
staggered_screen_trickle9defended0.731watch
synchronized_ring9breached0.151watch
phase_locked_ring9breached0.143watch
depth_shell_saturation9breached0.142watch
interleaved_shell_ring9breached0.125watch
staggered_trishell_blast_denial9breached0.146watch
shadow_pair_ring9defended0.531watch
blast_proof_depth_interleave9breached0.147watch
column_free_tiered_ring_dive9defended0.763watch
2026_10_15_attacker_dark_ring_release9defended0.748watch
Record · 2026-11-29_defender_defender_ring_triplet_neighbor_blast.meta.json
backendcli
date2026-11-29
dry_runFalse
escalationFalse
evidencebudget: 3500, dropped: [], included: ['source'], used: 2170
modelopus
name2026-11-29_defender_defender_ring_triplet_neighbor_blast
personacontrarian
prompt_version2026-10-03.1
raw_responseout/house_raw/2026-11-29T033634_cli_defender_contrarian.md
resultbeat_target: False, field_mean: 0.494, rank: 16, score_vs_target: 0.238
roledefender
target2026-11-15_attacker_attacker_radar_shadow_orbit_decoy_drain
tokensinput: 5539, output: 29467
Source · bots/house/2026-11-29_defender_defender_ring_triplet_neighbor_blast.py
"""Idea: Partition the incoming striker ring into bearing-adjacent triplets and time each interceptor so it meets the middle striker where the ring's own convergence has packed both neighbours inside one blast radius.

Core idea: ring-triplet neighbour blasts
---------------------------------------
The obvious counter to radar_shadow_orbit_decoy_drain is to refuse the decoy bait.
That means ID-gating, holding a reserve magazine for the second wave, or keeping a
sentinel interceptor airborne so the attacker's "count hit zero" trigger never fires.
Several ladder defenders already do one of these. None of them changes the arithmetic
that follows: 26 strikers against 20 interceptors one-on-one still lets three or more
strikers through to the gun.

This bot uses the striker ring's geometry against it. The ring is released from one
radius on one tick, so the strikers stay radially synchronised and the gap between
neighbours shrinks in proportion to their range. With 26 strikers the chord between
neighbours is about 0.24 * r. Inside a meet radius of about 36, one interceptor
detonating on a striker also covers both of its ring neighbours.

The bot works in two phases:
  1. Early shots. When strikers become ID'd at the 150 range, it fires one-on-one
     only at a contiguous arc of the ring. The size of that arc is solved each tick
     from: early shots + triplets still needed + miss margin <= magazine. Keeping the
     arc contiguous leaves the rest of the ring as an unbroken chain.
  2. Triplet shots. It partitions the surviving chain into triplets and holds fire
     until each triplet's middle striker reaches the range where the closing speed
     puts the meet point at a radius of about 36 or less. It then launches at the
     middle striker. A track that has missed comes back uncovered and is replanned.
     The gun takes stragglers.
Interceptors only ever go to tracks confirmed as strikers, so the decoy ring draws
nothing. The attacker's drain trigger then falls back to its idle timer, which does
not matter here.
"""

import math

NAME = "defender_ring_triplet_neighbor_blast"
ROLE = "defender"

_S = {}


def reset(seed=0):
    _S.clear()
    _S.update({
        "hist": {},        # track id -> list of (tick, dx, dy, r)
        "cls": {},         # sticky classification
        "ic_group": {},    # interceptor id -> set of covered track ids
        "pending": {},     # center track id -> members (launched, awaiting ic id)
        "pending_early": set(),
        "early_ics": set(),
    })


reset(0)

M_LAUNCH = 36.0
M_PLAN = 32.0
LINK = 10.5
WINDOW_R = 75.0


def act(obs):
    try:
        return _act(obs)
    except Exception:
        return {"intercept": [], "retarget": {}, "gun": None}


def _angwrap(a):
    return a % (2 * math.pi)


def _act(obs):
    tick = int(obs.get("tick", 0))
    rules = obs.get("rules", {}) or {}
    asset = obs.get("asset", {}) or {}
    ax, ay = (asset.get("pos") or [0.0, 0.0])[:2]
    tracks = obs.get("tracks", []) or []
    ics = obs.get("interceptors", []) or []
    stock = int(obs.get("stock", 0) or 0)
    ammo = int(obs.get("ammo", 0) or 0)
    vi = float(rules.get("interceptor_speed", 12.0))
    vs_rule = float(rules.get("striker_speed", 4.0))
    gun_range = float(rules.get("gun_range", 100.0))
    per_tick = int(rules.get("interceptor_launches_per_tick", 2))
    asset_r = float(rules.get("asset_radius", 25.0))

    hist = _S["hist"]
    scls = _S["cls"]
    tr = {}
    for t in tracks:
        tid = t.get("id")
        if tid is None:
            continue
        px, py = (t.get("pos") or [0.0, 0.0])[:2]
        dx, dy = px - ax, py - ay
        r = math.hypot(dx, dy)
        tr[tid] = (dx, dy, r)
        h = hist.setdefault(tid, [])
        h.append((tick, dx, dy, r))
        if len(h) > 20:
            del h[0]
        c = t.get("cls", "unknown")
        if c in ("striker", "decoy"):
            scls[tid] = c
    for tid in list(hist.keys()):
        if tid not in tr:
            del hist[tid]

    def cls_of(tid):
        return scls.get(tid, "unknown")

    fit_cache = {}

    def fit(tid):
        if tid in fit_cache:
            return fit_cache[tid]
        h = hist.get(tid, [])
        pts = h[-8:]
        if len(pts) < 3:
            res = (tr[tid][2], -vs_rule)
        else:
            n = len(pts)
            mt = sum(p[0] for p in pts) / n
            mr = sum(p[3] for p in pts) / n
            sxx = sum((p[0] - mt) ** 2 for p in pts)
            sxy = sum((p[0] - mt) * (p[3] - mr) for p in pts)
            slope = sxy / sxx if sxx > 1e-9 else -vs_rule
            res = (mr + slope * (tick - mt), slope)
        fit_cache[tid] = res
        return res

    bear_cache = {}

    def bear(tid):
        if tid in bear_cache:
            return bear_cache[tid]
        h = hist.get(tid, [])
        sx = sum(p[1] for p in h)
        sy = sum(p[2] for p in h)
        if abs(sx) + abs(sy) < 1e-9:
            dx, dy, _ = tr[tid]
            sx, sy = dx, dy
        b = _angwrap(math.atan2(sy, sx))
        bear_cache[tid] = b
        return b

    def rho(tid):
        return max(0.0, fit(tid)[0])

    def closing(tid):
        s = -fit(tid)[1]
        return min(max(s, 1.0), vs_rule * 1.5)

    def meet(tid):
        v = closing(tid)
        return rho(tid) * vi / (vi + v)

    # ---- interceptor bookkeeping ----
    ic_group = _S["ic_group"]
    pending = _S["pending"]
    alive_ic = set()
    for ic in ics:
        iid = ic.get("id")
        if iid is None:
            continue
        alive_ic.add(iid)
        tgt = ic.get("target")
        if iid not in ic_group:
            if tgt in pending:
                ic_group[iid] = set(pending[tgt])
            else:
                ic_group[iid] = {tgt}
            if tgt in _S["pending_early"]:
                _S["early_ics"].add(iid)
    for iid in list(ic_group.keys()):
        if iid not in alive_ic:
            del ic_group[iid]
            _S["early_ics"].discard(iid)
    pending.clear()
    _S["pending_early"].clear()

    strikers = [tid for tid in tr if cls_of(tid) == "striker"]

    covered = set()
    for iid in alive_ic:
        covered |= (ic_group.get(iid, set()) & set(tr.keys()))

    retarget = {}
    for ic in ics:
        iid = ic.get("id")
        tgt = ic.get("target")
        if iid is None:
            continue
        if tgt in tr and cls_of(tgt) != "decoy":
            continue
        ipos = (ic.get("pos") or [ax, ay])[:2]
        ix, iy = ipos[0] - ax, ipos[1] - ay

        def dist(tid):
            dx, dy, _ = tr[tid]
            return math.hypot(dx - ix, dy - iy)

        grp = [m for m in ic_group.get(iid, set()) if m in tr and cls_of(m) != "decoy"]
        if not grp:
            grp = [s for s in strikers if s not in covered]
        if not grp:
            grp = list(strikers)
        if grp:
            new = min(grp, key=dist)
            retarget[iid] = new
            ic_group[iid] = {new}
            covered.add(new)

    # ---- grouping helpers ----
    def link_fn(mcap):
        def link(a, b):
            gap = _angwrap(bear(b) - bear(a))
            if gap > math.pi:
                return False
            m = min(mcap, meet(a), meet(b))
            m = max(m, asset_r)
            chord = 2.0 * m * math.sin(gap / 2.0)
            return chord <= LINK and abs(rho(a) - rho(b)) <= 10.0
        return link

    def runs(ids, link):
        ids = list(ids)
        if not ids:
            return []
        order = sorted(ids, key=bear)
        n = len(order)
        if n == 1:
            return [order]
        links = [link(order[i], order[(i + 1) % n]) for i in range(n)]
        if all(links):
            gaps = [_angwrap(bear(order[(i + 1) % n]) - bear(order[i])) for i in range(n)]
            k = max(range(n), key=lambda i: gaps[i])
            links[k] = False
        k = next(i for i in range(n) if not links[i])
        start = (k + 1) % n
        out = []
        cur = []
        for j in range(n):
            i = (start + j) % n
            cur.append(order[i])
            if not links[i]:
                out.append(cur)
                cur = []
        if cur:
            out.append(cur)
        return out

    def count_groups(ids):
        return sum((len(r) + 2) // 3 for r in runs(ids, link_fn(M_PLAN)))

    intercept = []
    slots = min(per_tick, stock)
    launched = set()

    # ---- window phase: triplet launches ----
    if slots > 0:
        W = [s for s in strikers if s not in covered and rho(s) <= WINDOW_R]
        groups = []
        for run in runs(W, link_fn(M_LAUNCH)):
            for i in range(0, len(run), 3):
                ch = run[i:i + 3]
                if len(ch) == 3:
                    c = ch[1]
                elif len(ch) == 2:
                    c = min(ch, key=rho)
                else:
                    c = ch[0]
                groups.append((min(rho(m) for m in ch), c, ch))
        groups.sort(key=lambda g: g[0])
        for urg, c, ch in groups:
            if slots <= 0:
                break
            v = closing(c)
            rho_launch = M_LAUNCH * (vi + v) / vi
            if len(ch) >= 2 and urg > rho_launch:
                continue
            intercept.append(c)
            pending[c] = set(ch)
            launched |= set(ch)
            covered |= set(ch)
            slots -= 1

    # ---- early phase: contiguous arc one-on-one ----
    if slots > 0:
        U = [s for s in strikers if s not in covered]
        if U:
            order = sorted(U, key=bear)
            n = len(order)
            if n > 1:
                gaps = [_angwrap(bear(order[(i + 1) % n]) - bear(order[i])) for i in range(n)]
                k = max(range(n), key=lambda i: gaps[i])
                order = order[k + 1:] + order[:k + 1]
            cand = [s for s in order if rho(s) > WINDOW_R]
            stock_after = stock - len(intercept)
            inflight_early = len(_S["early_ics"] & alive_ic)
            uset = set(U)
            K = 0
            for k2 in range(len(cand), -1, -1):
                rem = uset - set(cand[:k2])
                g = count_groups(rem)
                need = k2 + g + int(math.ceil(0.15 * (k2 + inflight_early)))
                if need <= stock_after:
                    K = k2
                    break
            if K == 0 and cand and count_groups(uset) >= len(uset):
                K = len(cand)
            for s in cand[:K]:
                if slots <= 0:
                    break
                intercept.append(s)
                pending[s] = {s}
                _S["pending_early"].add(s)
                covered.add(s)
                slots -= 1

    # ---- gun ----
    gun = None
    if ammo > 0:
        inr = [s for s in strikers if tr[s][2] <= gun_range]
        if inr:
            gun = min(inr, key=lambda s: (s in covered and s not in launched, tr[s][2]))
        else:
            unk = [t for t in tr if cls_of(t) == "unknown" and tr[t][2] <= gun_range]
            if unk:
                gun = min(unk, key=lambda t: tr[t][2])

    return {"intercept": intercept, "retarget": retarget, "gun": gun}