Skip to content

ENH: Add ZeroResp strategy (#2 in Medium Pool benchmark) - #1495

Closed
Evreu1pro wants to merge 4 commits into
Axelrod-Python:devfrom
Evreu1pro:feat/zeroresp-strategy
Closed

ENH: Add ZeroResp strategy (#2 in Medium Pool benchmark)#1495
Evreu1pro wants to merge 4 commits into
Axelrod-Python:devfrom
Evreu1pro:feat/zeroresp-strategy

Conversation

@Evreu1pro

Copy link
Copy Markdown

What

Adds ZeroResp, an adaptive long-memory strategy for the iterated Prisoner's Dilemma.

Why

ZeroResp combines:

  1. Dynamic epoch extension — retaliation debt keeps the epoch open until compensated.
  2. Stochastic retaliation buffer (5 + U{1..10}) — delays punishment to avoid cascade wars and to disrupt short-horizon MDP / Q-learning estimates.
  3. Red line — permanent defection (is_red_line = True) after systemic abuse (dynamic threshold 2–3).
  4. Anti-raider — late-game exploit patterns trigger an immediate ban.
  5. Finite-horizon harvest — only when match length is known; skips never-defectors (grim-safe).

Pre-submission benchmarks (external sandbox): Axelrod medium pool rank #2 (median ≈ 2.918).

How to test

pytest axelrod/tests/strategies/test_zeroresp.py -q

Covered:

  • Initial move is always C
  • Single D queues buffered retaliation (not immediate)
  • Three systemic D actions set permanent is_red_line = True
  • reset() cleans state for multi-rep tournaments

Changes

  • axelrod/strategies/zeroresp.py — strategy
  • axelrod/tests/strategies/test_zeroresp.py — TestPlayer suite
  • axelrod/strategies/_strategies.py — registration (from ._strategies import * via strategies/__init__.py)
  • axelrod/data/all_classifiers.yml — classifier entry
  • docs/reference/strategy_index.rst — documentation automodule
  • docs/index.rst — strategy count doctest 243 → 244

Breaking

No — additive strategy only.

Adds an adaptive state-machine strategy with dynamic epochs, a stochastic
retaliation buffer (5 + U{1..10}), and a permanent red-line ban after
systemic defections. Includes unit tests (initial C, buffer queue, red line,
reset), strategy registration, classifier entry, and docs index update.
Adds tests for match-length edge cases, end-game harvest, anti-raider,
hostile live ban, and epoch/red-line close paths. Updates stochastic and
makes_use_of length filter counts after registering ZeroResp.
NumPy 2.x changes scalar repr (np.int64/np.float64) which breaks doctests,
match.scores output, and fingerprint probe string equality under CI.
Tox already pins numpy==1.26.4 for install_deps; package deps were upgrading
to 2.x via numpy>=1.26.4. Constrain the dependency and harden Point creation.
pytest already green (5252 passed, 100% coverage). CI failed on
black --check for test_zeroresp and a few pre-existing modules under
black 26.x. Format those files so tox commands[1] passes.
@Evreu1pro

Copy link
Copy Markdown
Author

Closing in favour of #1496, which includes ZeroResp and the tournament-ready ZeroResp v2 (rev 2.2), plus CI fixes and a fuller test suite.

Showcase package: https://github.com/Evreu1pro/ZeroResp

@Evreu1pro Evreu1pro closed this Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant