mirror of
https://github.com/donlucasx/xscapes.git
synced 2026-10-20 08:43:32 +02:00
The crab is a companion, not a replacement: five states, crablets on the sand, crablets in the water, and an exit queue that goes UNDER rather than swimming off -- a crab does not swim, it walks in, and the eyestalks carry on above the surface. Same 10x8 box as KittenSwim, so the lane arithmetic needed no new numbers. "Join" was costed at threading a companion interface through 25 production call sites. It needed none. The sprite data became a FIELD on the existing type, so NewCrab() returns what NewCat() returns and every call site is untouched; the refactor never left internal/companion. Measured, so nobody re-derives it: the crab's ink is 12x7 cells to the cat's 9x7, at 64-66 of 84 cells against the cat's 60 -- the same weight, arranged sideways. The three extra columns were always free, because cat.Size() returns the BOX and the cat has never used its last three. Coat LOCKED at salmon, cube index 210. An exact cube entry, so it survives the glyph path's 2.6x saturate unchanged. Every coat the cat ships is a near-neutral the boost ignores; this is the first companion colour with enough chroma that it had to be checked. Two defects its own tests found before he did, both of which the cat had already fixed: a crablet losing an eye to a neighbour's body at 16 subagents, and two swimmers sharing a lane. One cause -- column de-duplication bucketed as x/width, which does not prevent overlap. Replaced with an interval allocator that reserves the sprite AND its two ripple cells. The generated study pages are ignored, not committed: 15 MB of HTML that `go run ./notes/charstudy/crab` rebuilds. The generator is the record. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015GQLYhGnSpasru9xeJbJry
62 lines
1.6 KiB
Go
62 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/donlucasx/xscapes/internal/companion"
|
|
)
|
|
|
|
// dump prints a body as the quadrant glyphs it actually becomes, so the
|
|
// silhouette can be judged before a frame is spent on it. Build the instrument
|
|
// before trusting the picture.
|
|
func dump(name string, rows []string, w, h int) {
|
|
if len(rows) != h {
|
|
fmt.Printf("%s: BAD -- %d rows, want %d\n", name, len(rows), h)
|
|
return
|
|
}
|
|
for i, r := range rows {
|
|
if len(r) != w {
|
|
fmt.Printf("%s: BAD -- row %d is %d wide, want %d: %q\n", name, i, len(r), w, r)
|
|
return
|
|
}
|
|
}
|
|
q := companion.ParseBitmap(rows).ToQuadrant()
|
|
fmt.Printf("--- %s (%d x %d cells) ---\n", name, w/2, h/4)
|
|
for _, line := range q {
|
|
fmt.Printf(" |%s|\n", strings.ReplaceAll(line, " ", "."))
|
|
}
|
|
fmt.Println()
|
|
}
|
|
|
|
// extent measures how much of the 12x7 box a body actually fills: the ink
|
|
// bounding box in cells and how many cells carry ink. "Is it as big as the cat"
|
|
// is a question about ink, not about the box -- every companion shares the box.
|
|
func extent(name string, rows []string) (w, h, filled int) {
|
|
q := companion.ParseBitmap(rows).ToQuadrant()
|
|
minX, maxX, minY, maxY := 99, -1, 99, -1
|
|
for y, line := range q {
|
|
// []rune, not a byte range: a quadrant glyph is three bytes, so ranging
|
|
// the string gives byte offsets and reports a 12-cell body as 34 wide.
|
|
for x, r := range []rune(line) {
|
|
if r == ' ' {
|
|
continue
|
|
}
|
|
filled++
|
|
if x < minX {
|
|
minX = x
|
|
}
|
|
if x > maxX {
|
|
maxX = x
|
|
}
|
|
if y < minY {
|
|
minY = y
|
|
}
|
|
if y > maxY {
|
|
maxY = y
|
|
}
|
|
}
|
|
}
|
|
return maxX - minX + 1, maxY - minY + 1, filled
|
|
}
|