Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Google deepmind Dm control Soccer Task

From Leeroopedia
Revision as of 12:43, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Google_deepmind_Dm_control_Soccer_Task.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Metadata
Knowledge Sources dm_control
Domains Multi-Agent Reinforcement Learning, Game Design
Last Updated 2026-02-15 00:00 GMT

Overview

Concrete tool for defining the scoring, reward, termination, and ball-reset rules of a multi-agent MuJoCo soccer game through the Task and MultiturnTask classes.

Description

The soccer task module provides two Composer task classes:

  • Task -- Implements a single-turn game. The episode terminates as soon as either team scores a goal. The discount drops to 0 upon a goal event.
  • MultiturnTask -- Extends Task to implement continuous play. Goals trigger a position reinitialisation and ball tracker reset rather than episode termination. The discount remains 1 throughout and should_terminate_episode always returns False.

Both classes share the same constructor signature and manage:

  • Attaching walkers and ball to the arena.
  • Registering ball contact tracking per player.
  • Adding per-player observables via an ObservablesAdder.
  • Dispatching per-player actions during before_step.
  • Detecting out-of-court events and performing throw-ins (repositioning the ball inward with zero velocity).
  • Computing per-player rewards (+1 / -1 / 0) and multi-agent action specs.

Usage

Task and MultiturnTask are selected automatically by soccer.load() based on the terminate_on_goal flag. They can also be instantiated directly for custom arena or initialiser configurations.

Code Reference

Attribute Value
Source Location dm_control/locomotion/soccer/task.py, lines 36--267
Signature (Task) Task(players, arena, ball=None, initializer=None, observables=None, disable_walker_contacts=False, nconmax_per_player=200, njmax_per_player=400, control_timestep=0.025, tracking_cameras=())
Signature (MultiturnTask) MultiturnTask(players, arena, ball=None, initializer=None, observables=None, disable_walker_contacts=False, nconmax_per_player=200, njmax_per_player=400, control_timestep=0.025, tracking_cameras=())
Import from dm_control.locomotion.soccer import Task, MultiturnTask

I/O Contract

Inputs (constructor):

Parameter Type Description
players list[Player] Sequence of Player namedtuples from both teams.
arena Pitch or RandomizedPitch The physical pitch with goal sensors and field boundaries.
ball SoccerBall or None Soccer ball entity; defaults to SoccerBall().
initializer Initializer or None Episode initialiser; defaults to UniformInitializer().
observables ObservablesAdder or None Per-player observables factory; defaults to CoreObservablesAdder().
disable_walker_contacts bool If True, set contype=0 on all walker geoms.
nconmax_per_player int Max contacts per player (MuJoCo buffer size). Default 200.
njmax_per_player int Max scalar constraints per player. Default 400.
control_timestep float Agent control timestep in seconds. Default 0.025.
tracking_cameras tuple Sequence of MultiplayerTrackingCamera instances.

Outputs (per-step):

Method Return Type Description
get_reward(physics) list[np.ndarray] List of scalar float32 arrays, one per player (+1, -1, or 0).
should_terminate_episode(physics) bool True if a goal was detected (Task); always False (MultiturnTask).
get_discount(physics) np.ndarray Scalar float32: 0.0 on goal (Task), always 1.0 (MultiturnTask).
action_spec(physics) list[specs.BoundedArray] Per-player action specifications determined by walker morphology.

Usage Examples

from dm_control.locomotion import soccer

# --- Single-turn task (episode ends on goal) ---
players = soccer._make_players(team_size=2, walker_type=soccer.WalkerType.BOXHEAD)
arena = soccer.RandomizedPitch(
    min_size=(32, 24), max_size=(48, 36), keep_aspect_ratio=False)
task = soccer.Task(players=players, arena=arena)
print(type(task))  # <class 'dm_control.locomotion.soccer.task.Task'>

# --- Multi-turn task (continuous play) ---
multiturn = soccer.MultiturnTask(players=players, arena=arena)
print(multiturn.should_terminate_episode(None))  # False (always)

# --- Using through soccer.load (recommended) ---
env = soccer.load(team_size=2, terminate_on_goal=True)   # uses Task
env = soccer.load(team_size=2, terminate_on_goal=False)  # uses MultiturnTask

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment