"""Learner work: implement these functions without importing the supplied reference.
Use ordinary lists/dicts and the same 9–8–4 tanh architecture. Public checks are
practice. Submit your implementation and explanations for separate human review.
"""
def transition(state, action):
    """Return state/action/next/reward/terminal. Reject terminal starts.
    Cells are row-major in a 3x3 grid. Actions Up/Right/Down/Left.
    Goal 8: +10 terminal; hazard 5: -10 terminal; otherwise -1.
    Boundary bumps stay in place. Raise ValueError for invalid commands.
    """
    raise NotImplementedError('Implement exact transition and task termination')

def stopped_target(receipt, next_values):
    """reward + .9 * max(next_values) for nonterminal receipts only."""
    raise NotImplementedError('Distinguish task termination from collection reset')

def gradient(online, target, batch):
    """Return (gradient_dict, mean_half_squared_error).
    w1 has 8x9 row-major weights; b1 has 8. tanh hidden units feed
    w2 (4x8 row-major) and b2 (4). State is a one-hot input.
    Repeated receipts contribute repeatedly. Hold target fixed.
    Differentiate all online parameters from the same preceding network.
    """
    raise NotImplementedError('Implement a stopped-target minibatch gradient')
