Skip to content
MARL in Cooperative Environments
Edit this page

Code exercise gallery

A fixture, not a lesson. Every exercise state is exercised here so a regression in the Python runtime shows up in one place.

Python runs entirely in your browser through Pyodide. The runtime is about 10 MB and downloads once, on the first Run or Check, never on page load.

Exercise

Cooperative reward

Implement the reward from the Coordinate chapter, then use Check to test it against all four joint actions.

def team_reward(a, b):
    """Return +1 when the channels differ, -1 when they collide."""
    # TODO: replace this with the reward rule
    return 0
Exercise

Jain's fairness index

The fairness metric used throughout the wireless lab.

def jain(rates):
    """J = (sum x)^2 / (n * sum x^2)"""
    # TODO
    return 0.0

An exercise whose starter code raises, so the error path is visible: the checks should not run at all, and the traceback should mention only the learner’s own code.

Exercise

Deliberately broken starter

Press Check. The runtime should report that the code raised before the checks could run, rather than listing failed assertions.

def add(a, b):
    return a + undefined_name