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
91 lines
3.0 KiB
Go
91 lines
3.0 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/donlucasx/xscapes/internal/canvas"
|
|
"github.com/donlucasx/xscapes/internal/scape"
|
|
"github.com/donlucasx/xscapes/internal/term"
|
|
)
|
|
|
|
func dist(a, b term.RGB) float64 {
|
|
dr, dg, db := float64(a.R)-float64(b.R), float64(a.G)-float64(b.G), float64(a.B)-float64(b.B)
|
|
return dr*dr + dg*dg + db*db
|
|
}
|
|
|
|
// discProbe finds every cell still drawn as a half block and reports how far
|
|
// apart its two halves are. A half block leaves a one-pixel rule at the cell's
|
|
// bottom edge whichever way up it is drawn -- but the rule is painted in the
|
|
// cell's BACKGROUND, which is the other half's colour. So when the two halves
|
|
// are nearly the same colour the split buys nothing and the rule is the only
|
|
// thing it produces.
|
|
func discProbe(seed int64) {
|
|
term.LowerHalf = term.DetectSplit("Apple_Terminal")
|
|
term.NoSplitCells = term.DetectNoSplit("Apple_Terminal")
|
|
w := 126
|
|
type bucket struct{ n, edge, interior int }
|
|
buckets := map[string]*bucket{}
|
|
var samples []string
|
|
totalSplit, interior := 0, 0
|
|
for _, h := range []int{20, 24, 28, 30, 34, 40, 47} {
|
|
for i := 0; i < 48; i++ {
|
|
tod := float64(i) / 48
|
|
c := canvas.New(w, h, canvas.AlphaFar, canvas.AlphaMid, canvas.AlphaNear)
|
|
sh := scape.NewShore(seed, false)
|
|
sh.MoonX = 0.28
|
|
act := scape.Activity{Working: true, Level: 0.55, TimeOfDay: tod, ContextUsed: 0.3}
|
|
for k := 0; k < 12; k++ {
|
|
sh.Update(c, 3+float64(k)/40, act)
|
|
}
|
|
for y := 0; y < sh.SandTop(); y++ {
|
|
for x := 0; x < w; x++ {
|
|
r, fg, bg := c.ResolveAt(x, y, term.Profile256)
|
|
if r != '▄' && r != '▀' {
|
|
continue
|
|
}
|
|
if !sh.DiscCovers(x, y) {
|
|
continue // only the sun and the moon
|
|
}
|
|
// An INTERIOR cell is one whose neighbours above and below
|
|
// are also disc; an edge cell is not. A rule across the
|
|
// face comes from the interior ones.
|
|
if sh.DiscCovers(x, y-1) && sh.DiscCovers(x, y+1) {
|
|
interior++
|
|
}
|
|
totalSplit++
|
|
d := dist(fg, bg)
|
|
key := "far (>2000)"
|
|
switch {
|
|
case d == 0:
|
|
key = "IDENTICAL"
|
|
case d < 300:
|
|
key = "near (<300)"
|
|
case d < 2000:
|
|
key = "mid (<2000)"
|
|
}
|
|
if buckets[key] == nil {
|
|
buckets[key] = &bucket{}
|
|
}
|
|
buckets[key].n++
|
|
if len(samples) < 8 && d > 0 && d < 2000 {
|
|
samples = append(samples, fmt.Sprintf(
|
|
" h=%d tod=%.2f (%2d,%2d) up %3d,%3d,%3d down %3d,%3d,%3d dist %.0f",
|
|
h, tod, x, y, bg.R, bg.G, bg.B, fg.R, fg.G, fg.B, d))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
fmt.Printf("Half-block cells ON THE DISC across 7 heights x 48 half-hours: %d\n", totalSplit)
|
|
fmt.Printf(" of those, INTERIOR (a rule across the face): %d\n\n", interior)
|
|
for _, k := range []string{"IDENTICAL", "near (<300)", "mid (<2000)", "far (>2000)"} {
|
|
if b := buckets[k]; b != nil {
|
|
fmt.Printf(" %-14s %6d (%.1f%%)\n", k, b.n, float64(b.n)/float64(totalSplit)*100)
|
|
}
|
|
}
|
|
fmt.Println("\nsamples of the low-contrast splits -- the ones that buy nothing:")
|
|
for _, s := range samples {
|
|
fmt.Println(s)
|
|
}
|
|
}
|