Skip to content

Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.

refactor(prompt): the kinds of a prompt note, conflict and repeat, are named once in gen/prompt_parts.py as CONFLICT and REPEAT, which Prompt.note writes and note_lines and video-prompt's warning list read

Soohong Kim2940a15c0eab
diff --git a/sprite_gen/gen/prompt_parts.py b/sprite_gen/gen/prompt_parts.py
index fcc8369..d0b2629 100644
--- a/sprite_gen/gen/prompt_parts.py
+++ b/sprite_gen/gen/prompt_parts.py
@@ -52,6 +52,8 @@ _CLAUSE_END = re.compile(r"[.;:!?\n]+")
# `facing` of a piece whose view is turned to neither side (front, back).
NO_TURN = "neither"
+# The kind of a note in `Prompt.notes`: the caller's text says against a piece (a warning), or says it again.
+CONFLICT, REPEAT = "conflict", "repeat"
def turns_said(text: str) -> list[tuple[str, str]]:
@@ -138,12 +140,12 @@ class Prompt:
if facing is not None:
for words, side in turns_said(self.caller):
if facing == NO_TURN:
- self._say("conflict", "facing", f'the text says "{words}" and the engine\'s sentence is a view '
+ self._say(CONFLICT, "facing", f'the text says "{words}" and the engine\'s sentence is a view '
"turned to neither side")
elif side == facing:
- self._say("repeat", "facing", f'the text says "{words}" and so does the engine\'s sentence; it is said twice')
+ self._say(REPEAT, "facing", f'the text says "{words}" and so does the engine\'s sentence; it is said twice')
else:
- self._say("conflict", "facing", f'the text says "{words}" and the engine\'s sentence says {facing}')
+ self._say(CONFLICT, "facing", f'the text says "{words}" and the engine\'s sentence says {facing}')
for item in handed or []:
name = _ARTICLE.sub("", item.item).lower()
for clause in _CLAUSE_END.split(self.caller):
@@ -151,9 +153,9 @@ class Prompt:
continue
sides = {side.lower() for side in _SIDE.findall(_TURN.sub(" ", clause))}
if item.side in sides:
- self._say("repeat", "handed", f"the text already says which side {item.item} is on; it is said twice")
+ self._say(REPEAT, "handed", f"the text already says which side {item.item} is on; it is said twice")
elif item.other in sides:
- self._say("conflict", "handed", f'the text has {item.item} with "{item.other}" ("{clause.strip()}") '
+ self._say(CONFLICT, "handed", f'the text has {item.item} with "{item.other}" ("{clause.strip()}") '
f"and the engine's sentence puts it on the {item.where()}")
def _say(self, kind: str, about: str, text: str) -> None:
@@ -164,4 +166,4 @@ class Prompt:
def note_lines(prompt: Prompt) -> list[str]:
"""`prompt.notes` as lines for stderr: a conflict is a warning, a repeat a note."""
- return [("warning: " if note["kind"] == "conflict" else "note: ") + note["text"] for note in prompt.notes]
+ return [("warning: " if note["kind"] == CONFLICT else "note: ") + note["text"] for note in prompt.notes]
diff --git a/sprite_gen/video/clip_prompt.py b/sprite_gen/video/clip_prompt.py
index c4408e5..bca0498 100644
--- a/sprite_gen/video/clip_prompt.py
+++ b/sprite_gen/video/clip_prompt.py
@@ -26,6 +26,7 @@ from pathlib import Path
from typing import Any
from sprite_gen.frames.cutout import GREEN
+from sprite_gen.gen import prompt_parts
from sprite_gen.gen.chroma import KEY_BACKGROUND_TEXT
from sprite_gen.gen.facing import FACINGS
from sprite_gen.gen import handedness as handed_mod
@@ -82,7 +83,7 @@ def plan_prompt(*, direction: str, state: str, facing: str = "right", character:
model=model, handed=handed, body_plan=body_plan, play=play)
prompt = parts.text
# the caller's own words (--character, --motion) against the engine's: a conflict is a warning
- warnings += [note["text"] for note in parts.notes if note["kind"] == "conflict"]
+ warnings += [note["text"] for note in parts.notes if note["kind"] == prompt_parts.CONFLICT]
cycle = batch_mod.cycle_for(state, direction, play, pinned=pins)
# as video-set places and cuts: a side or diagonal view takes the facing, front and back face right
canvas_facing = loop_facing = facing if direction in handed_mod.LATERAL_VIEWS else "right"