Skip to content

ogs.dsl.types

Bases: Interface

The (X, Y, R, S) 4-tuple boundary of an open game.

Backwards-compatible constructor that maps game theory conventions to GDS directional pairs:

  • x → forward_in (observation inputs, covariant)
  • y → forward_out (decision outputs, covariant)
  • r → backward_in (utility inputs, contravariant)
  • s → backward_out (coutility outputs, contravariant)
Source code in packages/gds-games/ogs/dsl/types.py
class Signature(Interface, frozen=True):
    """The ``(X, Y, R, S)`` 4-tuple boundary of an open game.

    Backwards-compatible constructor that maps game theory conventions
    to GDS directional pairs:

    - **x** → forward_in (observation inputs, covariant)
    - **y** → forward_out (decision outputs, covariant)
    - **r** → backward_in (utility inputs, contravariant)
    - **s** → backward_out (coutility outputs, contravariant)
    """

    if TYPE_CHECKING:

        def __init__(
            self,
            *,
            x: tuple[Port, ...] = (),
            y: tuple[Port, ...] = (),
            r: tuple[Port, ...] = (),
            s: tuple[Port, ...] = (),
            forward_in: tuple[Port, ...] = (),
            forward_out: tuple[Port, ...] = (),
            backward_in: tuple[Port, ...] = (),
            backward_out: tuple[Port, ...] = (),
        ) -> None: ...

    @model_validator(mode="before")
    @classmethod
    def _map_xyrs(cls, data: dict) -> dict:
        if isinstance(data, dict):
            mapping = {
                "x": "forward_in",
                "y": "forward_out",
                "r": "backward_in",
                "s": "backward_out",
            }
            for old, new in mapping.items():
                if old in data:
                    data[new] = data.pop(old)
        return data

    @property
    def x(self) -> tuple[Port, ...]:
        return self.forward_in

    @property
    def y(self) -> tuple[Port, ...]:
        return self.forward_out

    @property
    def r(self) -> tuple[Port, ...]:
        return self.backward_in

    @property
    def s(self) -> tuple[Port, ...]:
        return self.backward_out

Bases: str, Enum

Classification of an open game component by its port structure.

Source code in packages/gds-games/ogs/dsl/types.py
class GameType(str, Enum):
    """Classification of an open game component by its port structure."""

    DECISION = "decision"
    FUNCTION_COVARIANT = "function_covariant"
    FUNCTION_CONTRAVARIANT = "function_contravariant"
    DELETION = "deletion"
    DUPLICATION = "duplication"
    COUNIT = "counit"

Bases: str, Enum

Semantic classification of an information flow between components.

Source code in packages/gds-games/ogs/dsl/types.py
class FlowType(str, Enum):
    """Semantic classification of an information flow between components."""

    OBSERVATION = "observation"
    CHOICE_OBSERVATION = "choice_observation"
    UTILITY_COUTILITY = "utility_coutility"
    PRIMITIVE = "primitive"

Bases: str, Enum

How games are composed within a pattern.

Extends GDS composition types with game-theory naming.

Source code in packages/gds-games/ogs/dsl/types.py
class CompositionType(str, Enum):
    """How games are composed within a pattern.

    Extends GDS composition types with game-theory naming.
    """

    SEQUENTIAL = "sequential"
    PARALLEL = "parallel"
    FEEDBACK = "feedback"
    CORECURSIVE = "corecursive"

Bases: str, Enum

Classification of external inputs that cross the pattern boundary.

Source code in packages/gds-games/ogs/dsl/types.py
class InputType(str, Enum):
    """Classification of external inputs that cross the pattern boundary."""

    SENSOR = "sensor"
    RESOURCE = "resource"
    INITIALIZATION = "initialization"
    EXTERNAL_WORLD = "external_world"