Files
donlucasandClaude Fable 5.1 b58bcad9dc The moon is a disc at every height, and the companion steps back from the edge
His first live look at the palette paths, from a 124x52 window: "the moon
looks worse than before", and the companion "feels too pushed to the side
of the screen. a bit".

Measured before theorising (notes/moonprobe): the moon was identical with
the paths on and off. At the 23 rows that window gives the scape the disc's
radius is 1.92 rows, just under two, so the rows that would have been its
tips fell outside it and the three that remained were all seven cells wide.
A rectangle, at that height only; his earlier 62-row windows had a radius
of two and a disc. The disc is now sampled at half rows and painted with
U+2580 where its edge falls inside a row (canvas.SetBGHalves), and a test
holds it round from 18 to 30 rows, red first at 22 and 23.

The companion's margin from the right edge grows with the width: 2 + w/32,
five columns at 124 where it was two; narrower than the sprite it still
pins to the left so the face survives.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-04 00:47:31 -07:00

79 lines
2.0 KiB
Go

package term
import (
"fmt"
"testing"
)
// Does the cache key omit the raw (a,b) that produced it, so a SECOND call
// landing on the same quantised (s,g) bucket -- but from a genuinely
// different true-colour line -- gets the FIRST call's path regardless of
// its own geometry? Search across many (s,g) pairs for two distinct raw
// lines that share a bucket and where a direct (uncached) rampSearch call
// would pick different paths for the two lines.
func TestZZZCacheKeyOmitsRawEndpoints(t *testing.T) {
rampOnce.Do(rampInit)
type sample struct {
a, b RGB
}
// A grid of raw colour pairs, deliberately NOT snapped to cube entries,
// so many distinct (a,b) share a quantised bucket the way a slowly
// drifting palette does.
var samples []sample
for r := 0; r < 256; r += 23 {
for g := 0; g < 256; g += 41 {
for bl := 0; bl < 256; bl += 53 {
a := RGB{uint8(r), uint8(g), uint8(bl)}
b := RGB{uint8(255 - r), uint8((g + 90) % 256), uint8((bl + 60) % 256)}
samples = append(samples, sample{a, b})
}
}
}
t.Logf("samples: %d", len(samples))
type bucket struct{ s, g int }
seen := map[bucket]sample{}
diffs := 0
checked := 0
for _, s := range samples {
sa, sg := rampEnd(s.a), rampEnd(s.b)
if sa == sg {
continue
}
key := bucket{sa, sg}
first, ok := seen[key]
if !ok {
seen[key] = s
continue
}
// Same bucket, different raw endpoints (or same -- skip identical).
if first.a == s.a && first.b == s.b {
continue
}
checked++
p1 := rampSearch(first.a, first.b, sa, sg)
p2 := rampSearch(s.a, s.b, sa, sg)
if !samePath(p1, p2) {
diffs++
if diffs <= 5 {
fmt.Printf("BUCKET s=%d g=%d\n first a=%v b=%v -> %s\n second a=%v b=%v -> %s\n",
sa, sg, first.a, first.b, describe(p1), s.a, s.b, describe(p2))
}
}
}
fmt.Println("bucket collisions checked:", checked, " with a DIFFERENT fresh-search path:", diffs)
}
func samePath(a, b []RGB) bool {
if len(a) != len(b) {
return false
}
for i := range a {
if a[i] != b[i] {
return false
}
}
return true
}