def defector_reward_fn(num_cooperators: int) -> float:
    """Defectors get a mild benefit from defecting but cause a big bad event."""
    num_defectors = num_players - num_cooperators
    if num_defectors > 0:
      return -9.0
    raise ValueError(
        f'defector_reward_fn called when num_defectors = {num_defectors}'
    )
Defectors get a mild benefit from defecting but cause a big bad event.
examples/deprecated/modular/environment/forbidden_fruit.py