Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
fix(video): a front or back walk and a front run say which way the steps go
Soohong Kimbf1ea13e1792
diff --git a/docs/video-pipeline.md b/docs/video-pipeline.mdindex 442e4f8..b944a37 100644--- a/docs/video-pipeline.md+++ b/docs/video-pipeline.md@@ -82,6 +82,22 @@ stance … same height every time"). `video-set` carries those templatesname limbs — the first drafts said "bipedal … knees … arms pumping", which prompted aquadruped and a legless blob into a contradiction (2026-09-09).+A walk seen from the front or from behind, and a run seen from the front, take their own+sentence (`VIEW_MOTION_TEXT`) instead: the steps lift and land straight forward and back+under the body, toward the viewer or away from it "as if on a treadmill", and the body never+turns to the side, steps sideways or crosses its feet. The body-neutral walk sentence asks for+"an even left-right or front-back rhythm", and a character facing the viewer read that as+stepping sideways: crossed feet, side kicks, a body turned to three-quarters. Measured on+Grok (subscription), 480p 3 s, nine humanoid characters twice each, judged on frame sheets+with the variant hidden: a front walk kept its facing and walked in 7 of 18 clips with the+old sentence and 13 of 18 with the new one (none turned); a front run in 11 of 18 and 15+of 18. A back walk did as well with either (8 of 10). "on a treadmill" said as a place was+sometimes drawn under the feet; "as if on a treadmill" was not. A side view and a run seen+from behind keep the state's sentence (the second was not measured). A walk drawn at a+three-quarter angle kept that angle in about half the clips (6 of 10) with the old sentence+and in 5 of 10 with one that said to walk "toward the way its body faces in the image", and+otherwise mostly turned to a side view: no sentence tried held a three-quarter view.+An attack is one timed strike, not a repeat. `MOTION_TEXT["attack"]` asks for one attack: a windup(about 0.5 s), one strike in front (about 0.25 s), a held impact pose (about 0.3 s) and a recoveryto the exact starting stance (about 0.5 s), then `HOLD_TEXT["attack"]`:diff --git a/sprite_gen/video/batch.py b/sprite_gen/video/batch.pyindex da2ab05..2c68bfe 100644--- a/sprite_gen/video/batch.py+++ b/sprite_gen/video/batch.py@@ -92,6 +92,29 @@ MOTION_TEXT = {"cheer": "celebrates in place: rises into a raised, spread-out cheer pose, holds it for a beat, then settles back to the exact starting stance, repeating at an even rhythm.","wave": "waves in place: lifts one side into a friendly wave, sways it a few times, then settles back to the exact starting stance, repeating at an even rhythm.",}+# A walk seen from the front or from behind, and a run seen from the front, in place of the body-neutral+# sentences above. Asked for "an even left-right or front-back rhythm", a walk that faces the viewer+# stepped sideways, crossed its feet or turned the body to the side in most of the takes. These say which+# way the steps go and that the body does not turn; a side view keeps MOTION_TEXT, and so does a run seen+# from behind, which was not measured. "as if on a treadmill" keeps the treadmill a comparison: said as a+# place, it was sometimes drawn under the feet.+VIEW_MOTION_TEXT = {+ ("walk", "front"): (+ "walks in place toward the viewer, as if on a treadmill, without coming any closer: a steady walk cycle for "+ "this body type in which every step lifts and lands straight forward and back under the body, with clear "+ "repeating ground contacts. It never turns to the side, never steps sideways and never crosses its feet."+ ),+ ("walk", "back"): (+ "walks in place away from the viewer, as if on a treadmill, without moving any farther away: a steady walk "+ "cycle for this body type in which every step lifts and lands straight forward and back under the body, with "+ "clear repeating ground contacts. It never turns to the side, never steps sideways and never crosses its feet."+ ),+ ("run", "front"): (+ "runs in place toward the viewer, as if on a treadmill, without coming any closer: a fast run cycle for this "+ "body type in which every stride lifts and lands straight forward and back under the body, with clear "+ "repeating ground contacts. It never turns to the side, never steps sideways and never crosses its feet."+ ),+}COMMON_TEXT = ("2D game sprite animation. The character {motion} The character is {view}. Stays centered in the frame and does ""not move across the screen; the body and hair always stay fully inside the frame with margin. Camera completely "@@ -158,7 +181,9 @@ def build_prompt(direction: str, state: str, character: str | None, facing: strrepeat = f" {REPEAT_TEXT[state]}" if state in REPEAT_TEXT else ""subject = character.strip().rstrip(".") if character else "The character"return f"2D game sprite animation. {motion}{hold}{repeat} {subject} is {view}." + template[len(head):]- text = template.format(motion=MOTION_TEXT.get(state, f"performs the '{state}' action in place, repeating at an even rhythm."), view=view)+ built_in = VIEW_MOTION_TEXT.get((state, direction)) or MOTION_TEXT.get(+ state, f"performs the '{state}' action in place, repeating at an even rhythm.")+ text = template.format(motion=built_in, view=view)return text.replace("The character", character, 1) if character else textdiff --git a/tests/video/test_video_pipeline.py b/tests/video/test_video_pipeline.pyindex 42c8241..fe69085 100644--- a/tests/video/test_video_pipeline.py+++ b/tests/video/test_video_pipeline.py@@ -486,10 +486,31 @@ def test_prompt_uses_state_and_view_and_optional_character() -> None:assert "The character" in batch_mod.build_prompt("back", "jump", None)+def test_front_and_back_gaits_say_which_way_the_steps_go() -> None:+ for state, direction, opening in (+ ("walk", "front", "walks in place toward the viewer"),+ ("walk", "back", "walks in place away from the viewer"),+ ("run", "front", "runs in place toward the viewer"),+ ):+ sentence = batch_mod.VIEW_MOTION_TEXT[(state, direction)]+ p = batch_mod.build_prompt(direction, state, None)+ assert p == batch_mod.COMMON_TEXT.format(motion=sentence, view=batch_mod.VIEW_TEXT[direction])+ assert f"{opening}, as if on a treadmill" in p+ assert "never turns to the side, never steps sideways and never crosses its feet" in p+ assert "left-right" not in p and "on a treadmill:" not in p+ # A side view, a run from behind and every other front or back state keep the state's own sentence.+ assert batch_mod.MOTION_TEXT["walk"] in batch_mod.build_prompt("side", "walk", None)+ assert batch_mod.MOTION_TEXT["run"] in batch_mod.build_prompt("side", "run", None)+ assert batch_mod.MOTION_TEXT["run"] in batch_mod.build_prompt("back", "run", None)+ assert batch_mod.MOTION_TEXT["idle"] in batch_mod.build_prompt("back", "idle", None)+ named = batch_mod.build_prompt("back", "walk", "The armored knight")+ assert named.startswith("2D game sprite animation. The armored knight walks in place away from the viewer")++def test_motion_templates_do_not_assume_a_body_plan() -> None:# the templates were first written for a biped; a quadruped or a legless blob must not# be prompted into a contradiction (2026-09-09 generalization run)- for state, text in batch_mod.MOTION_TEXT.items():+ for state, text in [*batch_mod.MOTION_TEXT.items(), *batch_mod.VIEW_MOTION_TEXT.items()]:for word in ("bipedal","knees",