Files
donlucasandClaude Opus 5 c0c1dabf0b The crab walks up to you before it asks, behind XSCAPES_NEAR
HIS IDEA, 2026-09-10: "can we animate the main Agent/companion to come CLOSER
to the user before it prompts it? So the companion (crab, in this case) would
walk up closer to the screen and get bigger." Then, on seeing it: "yes, lets
test the bigger crab- it should walk up closer to prompt, without overlapping
sub agents. OK if a part of its body is cut on the bottom of the screen."

OFF by default. XSCAPES_NEAR=1 is the authored 16x9; =2 is the exact 2x at
24x14, which clips. Two rungs because he picks from rendered options, the way
he picked Hero from four silhouettes and the coat from five.

⭐ HIS BOTTOM-CLIPPING PERMISSION IS WHAT SHAPES IT, and it voided the
constraint that killed two of the four drafted directions. The ceiling was
never the sprite's HEIGHT -- it is its TOP ROW staying out of the sea. So the
sprite is anchored by its top row at exactly the y the shipped crab draws at
and grows DOWNWARD: 12x7 -> 16x9 -> 24x14. "The top row never enters the sea"
becomes structural rather than arithmetic, because it does not move at all.
Plot and PlotOn already bounds-check, so there is no clipping logic anywhere.

Rung 2 is GENERATED by doubling every source pixel, never hand-typed, so it
cannot drift from the shipped art and every state and claw frame comes free.
⚠ Its measured cost is in the comment: the glyph vocabulary collapses 11 -> 3
and every diagonal becomes a one-cell staircase.

THE EYE IS A BITMAP NOW. A glyph cannot be scaled -- one cell on a 24-wide body
is 0.30% of the sprite against 1.19% today. Four cells of 336 is 1.19% exactly.
Alert is a RING, and every cell goes through PlotOn with the coat as ground so
the hole is salmon and not sea. ⭐ It buys something nobody asked for:
ask-vs-working becomes a SHAPE difference, which at one cell it never was.

Approach() eases one rung per stepDur, pace.go's own constant, and the retreat
is the same call running back -- so Worried arriving mid-ask walks the animal
home instead of cutting.

⚠ Measured: 61 -> 106 -> 188 ink cells; rung 2 clips 5 of its 14 rows, taking
the lower legs and keeping claws, eyes, shell and upper legs.

Off-by-default is proved against a pristine HEAD build, not against reasoning:
126 frames over 7 widths x 6 heights x 3 hours, 0 differing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FpWuRRqmoTMo6ayCkx9yYZ
2026-09-10 19:57:02 -07:00

187 lines
4.6 KiB
Go

package main
import (
"fmt"
"strings"
"github.com/donlucasx/xscapes/internal/companion"
)
// The harness. Everything here goes through companion.ParseBitmap and
// ToQuadrant, so what is printed is exactly what the scape would paint -- the
// same halve-then-pack that the shipped drawCrab uses, plus the eye glyphs
// plotted on top the way drawCrab plots them.
// pose is one authored frame: an upper half, and where the eye glyph goes.
type pose struct {
name string
upper []string
lower []string // nil means the shipped crabLower
eyes [2]int // eye CELLS in the authored, unmirrored box
row int // eye CELL row
glyph rune
note string
}
// render composes upper+lower, packs to quadrants, and plots the eyes on top,
// exactly as drawCrab does (mirror included).
func render(p pose, mirror bool, lift int) []string {
low := p.lower
if low == nil {
low = crabLower
}
rows := append(append([]string{}, p.upper...), low...)
src := companion.ParseBitmap(rows)
f := src.Blank()
for sy := 0; sy < f.H; sy++ {
for sx := 0; sx < f.W; sx++ {
if srcAt(src, sx, sy+lift) {
f.Set(sx, sy)
}
}
}
if mirror {
f = f.Mirrored()
}
q := f.ToQuadrant()
w := f.W / 2
out := make([]string, len(q))
copy(out, q)
for _, e := range p.eyes {
ex := e
if mirror {
ex = w - 1 - e
}
if p.row < 0 || p.row >= len(out) {
continue
}
r := []rune(out[p.row])
for len(r) <= ex {
r = append(r, ' ')
}
r[ex] = p.glyph
out[p.row] = string(r)
}
return out
}
// srcAt: Bitmap.at is unexported, so read the same way through ToQuadrant's
// public surface -- a one-pixel probe bitmap would be silly, so re-derive it.
func srcAt(b *companion.Bitmap, x, y int) bool {
if x < 0 || y < 0 || x >= b.W || y >= b.H {
return false
}
return b.On[y*b.W+x]
}
// inkCells counts painted cells, which is the only honest measure of "how big
// does it look" when the box cannot change.
func inkCells(rows []string) int {
n := 0
for _, r := range rows {
for _, c := range r {
if c != ' ' {
n++
}
}
}
return n
}
// quads counts painted QUARTER cells, which is the honest measure of apparent
// size in this medium. Counting whole cells scores a half block the same as a
// full one, and half the drafts here trade one for the other -- an open pincer
// paints fewer cells and more air without the animal getting any smaller.
//
// The count is taken off the halved bitmap, because that is what the quadrant
// glyphs actually paint: 24 wide by 14 tall, so 336 is a solid 12x7 box.
func quads(p pose) int {
low := p.lower
if low == nil {
low = crabLower
}
rows := append(append([]string{}, p.upper...), low...)
b := companion.ParseBitmap(rows)
n := 0
for y := 0; y < (b.H+1)/2; y++ {
for x := 0; x < b.W; x++ {
if srcAt(b, x, y*2) || srcAt(b, x, y*2+1) {
n++
}
}
}
return n
}
// topInk is the first cell row that carries any ink.
func topInk(rows []string) int {
for i, r := range rows {
if strings.TrimSpace(r) != "" {
return i
}
}
return len(rows)
}
// strip prints poses side by side with a gutter, so the progression reads in
// one look instead of one frame at a time.
func strip(title string, ps []pose, mirror bool, lifts []int) {
fmt.Printf("\n%s%s\n", title, map[bool]string{true: " (MIRRORED -- as shipped, companion on the right)", false: " (authored)"}[mirror])
var cols [][]string
for i, p := range ps {
lift := 0
if lifts != nil {
lift = lifts[i]
}
cols = append(cols, render(p, mirror, lift))
}
head := ""
for i, p := range ps {
head += fmt.Sprintf("%-14s", fmt.Sprintf("%d %s", i, p.name))
}
fmt.Println(head)
for r := 0; r < 7; r++ {
line := ""
for _, c := range cols {
cell := ""
if r < len(c) {
cell = c[r]
}
line += fmt.Sprintf("%-14s", cell)
}
fmt.Println(line)
}
stat := ""
for _, c := range cols {
stat += fmt.Sprintf("%-14s", fmt.Sprintf("%d cells", inkCells(c)))
}
fmt.Println(stat)
stat = ""
for i, c := range cols {
stat += fmt.Sprintf("%-14s", fmt.Sprintf("eye r%d c%d,%d", ps[i].row, ps[i].eyes[0], ps[i].eyes[1]))
_ = c
}
fmt.Println(stat)
}
// pair prints two poses stacked with a caption, for the A/B against the
// shipped ask.
func pair(a, b pose, mirror bool) {
ra, rb := render(a, mirror, 0), render(b, mirror, 0)
fmt.Printf("\n%-16s %-16s\n", a.name, b.name)
for r := 0; r < 7; r++ {
x, y := "", ""
if r < len(ra) {
x = ra[r]
}
if r < len(rb) {
y = rb[r]
}
fmt.Printf("%-16s %-16s\n", x, y)
}
fmt.Printf("%-16s %-16s\n", fmt.Sprintf("%d cells, top r%d", inkCells(ra), topInk(ra)),
fmt.Sprintf("%d cells, top r%d", inkCells(rb), topInk(rb)))
}