Pular para conteúdo

tucoopy.io.animation_spec

JSON-ready animation spec dataclasses.

This module defines a small set of dataclasses that match the animation/spec contract used by the JS demo renderer, plus helpers to build specs from:

  • a tucoopy.base.game.Game object, and
  • a sequence of allocations (frames).
Notes

AnimationSpec.to_json uses ensure_ascii=True to produce a strictly ASCII JSON string (any non-ASCII content is escaped). This keeps the output portable across environments while still being valid UTF-8 when written to disk.

Examples:

>>> from tucoopy import Game
>>> from tucoopy.io.animation_spec import build_animation_spec
>>> g = Game.from_coalitions(
...     n_players=2,
...     values={(): 0.0, (0,): 0.0, (1,): 0.0, (0, 1): 1.0},
... )
>>> spec = build_animation_spec(game=g, series_id="demo", allocations=[[0.0, 1.0]], dt=1/60)
>>> spec.schema_version
'0.1.0'