mirror of
https://github.com/donlucasx/xscapes.git
synced 2026-10-20 08:43:32 +02:00
His two reports of 2026-09-06, from long live sessions. The sun. lit = 1 - ContextUsed and the terminator is a second disc sliding across at 2*rr*lit, so a slate mass grew on the SUN as the context filled and cleared at a compaction -- "the Sun seems to break sometimes, and fix itself". Measured in his 134x71 frame at 49%: the lit body ends at x677 and the slate runs on to x719, 2.6 cells past it. His ruling: the sun wanes as a crescent. The unlit face is no longer painted by day; at night the moon keeps its shaded face, which is what stopped a moon one column into its phase reading as bitten. SunShadow = "slate" keeps the old look for the study. The thin lines are NOT fixed here, they are measured. U+2584's ink runs from 17 to 29.4 of a 30px row, not to 30 -- the "bottom-exact" reading of 2026-09-05 was half a logical pixel out. The last device pixel row of every split cell falls back to the cell's background, the row below carries the lower colour by construction, and it reads as a rule across a flat band: 5 in his sky, 4 more inside the disc. It is every two-colour cell, not the sun and not the ramp specifically, and U+2580 is worse (its ink starts 5px down). notes/lineprobe draws a frame with Terminal.app's measured geometry so the hairline is visible in a browser; a page that paints a split cell as two flat halves cannot show it. He is testing his terminal's line spacing before ruling on what to trade. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
131 lines
4.1 KiB
Go
131 lines
4.1 KiB
Go
package scape
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/donlucasx/xscapes/internal/canvas"
|
|
"github.com/donlucasx/xscapes/internal/term"
|
|
)
|
|
|
|
// The quad-edge disc is one clean container: at every phase the disc's
|
|
// cells (lit or dark) form ONE connected silhouette, the dark face forms one
|
|
// connected region, and the lit face carries ONE tone. His 2026-09-05 note
|
|
// on the study: "the 'empty shadow' it leaves as context depletes is
|
|
// broken/messy. Should be a clean container underneath."
|
|
func TestTheQuadDiscIsOneCleanContainer(t *testing.T) {
|
|
const w, h = 130, 22
|
|
for _, used := range []float64{0.05, 0.30, 0.60, 0.85} {
|
|
for _, tod := range []float64{0.556, 0.931} {
|
|
render := func(edge string) (*canvas.Canvas, *Shore) {
|
|
c := canvas.New(w, h, canvas.AlphaFar, canvas.AlphaMid, canvas.AlphaNear)
|
|
sh := NewShore(7, false)
|
|
sh.MoonX = 0.28
|
|
sh.MoonEdge = edge
|
|
sh.Update(c, 2, Activity{Working: true, Level: 0.65, ContextUsed: used, TimeOfDay: tod})
|
|
return c, sh
|
|
}
|
|
c, sh := render("quad")
|
|
control, _ := render("none") // the same frame without the disc
|
|
mx, my := sh.MoonPos()
|
|
rx, ry := sh.MoonExtent()
|
|
// The disc's cells are the ones that differ from the control frame;
|
|
// a sky tone that happens to round to the dark tone is not the disc.
|
|
lit := term.Profile256.Quantise(sh.litTone, false)
|
|
disc, darks := map[cellPt]bool{}, map[cellPt]bool{}
|
|
litTones := map[term.RGB]bool{}
|
|
for dy := -ry - 1; dy <= ry+1; dy++ {
|
|
for dx := -rx - 1; dx <= rx+1; dx++ {
|
|
x, y := mx+dx, my+dy
|
|
if x < 0 || y < 0 || x >= w || y >= h {
|
|
continue
|
|
}
|
|
ch, fg, bg := c.ResolveAt(x, y, term.Profile256)
|
|
ch0, fg0, bg0 := control.ResolveAt(x, y, term.Profile256)
|
|
if ch == ch0 && fg == fg0 && bg == bg0 {
|
|
continue
|
|
}
|
|
has := func(col term.RGB) bool { return bg == col || (ch != ' ' && fg == col) }
|
|
disc[cellPt{x, y}] = true
|
|
if sh.quadDark[[2]int{x, y}] {
|
|
darks[cellPt{x, y}] = true
|
|
}
|
|
if has(lit) {
|
|
if bg == lit {
|
|
litTones[bg] = true
|
|
} else {
|
|
litTones[fg] = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if n := regions(disc); n != 1 {
|
|
t.Errorf("used %.0f%% tod %.3f: the disc is %d regions, want one silhouette", used*100, tod, n)
|
|
}
|
|
// By day there is no unlit face to keep whole: the sun wanes as a
|
|
// crescent (his ruling, 2026-09-06). At night the moon still has
|
|
// one, and it must be ONE piece.
|
|
if !sh.night() {
|
|
if len(darks) != 0 {
|
|
t.Errorf("used %.0f%% tod %.3f: the sun carries %d unlit cells, want none", used*100, tod, len(darks))
|
|
}
|
|
} else if n := regions(darks); used > 0.1 && n != 1 {
|
|
var cells []cellPt
|
|
for p := range darks {
|
|
cells = append(cells, cellPt{p.x - mx, p.y - my})
|
|
}
|
|
t.Errorf("used %.0f%% tod %.3f: the dark face is %d regions, want one; dark cells (dx,dy): %v", used*100, tod, n, cells)
|
|
}
|
|
if len(litTones) > 1 {
|
|
t.Errorf("used %.0f%% tod %.3f: the lit face carries %d tones, want one", used*100, tod, len(litTones))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
type cellPt struct{ x, y int }
|
|
|
|
// regions counts 8-connected groups of cells.
|
|
func regions(cells map[cellPt]bool) int {
|
|
seen := map[cellPt]bool{}
|
|
n := 0
|
|
for p := range cells {
|
|
if seen[p] {
|
|
continue
|
|
}
|
|
n++
|
|
stack := []cellPt{p}
|
|
seen[p] = true
|
|
for len(stack) > 0 {
|
|
q := stack[len(stack)-1]
|
|
stack = stack[:len(stack)-1]
|
|
for dy := -1; dy <= 1; dy++ {
|
|
for dx := -1; dx <= 1; dx++ {
|
|
r := cellPt{q.x + dx, q.y + dy}
|
|
if cells[r] && !seen[r] {
|
|
seen[r] = true
|
|
stack = append(stack, r)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return n
|
|
}
|
|
|
|
// Night is a property of the sky, and the midday zenith is a dark saturated
|
|
// blue: it must not count. The halo and the sun's missing shadow both key
|
|
// on this.
|
|
func TestNightIsNotTheMiddayZenith(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
tod float64
|
|
night bool
|
|
}{{0.556, false}, {0.479, false}, {0.931, true}, {0.02, true}} {
|
|
sh := NewShore(7, false)
|
|
c := canvas.New(40, 12, canvas.AlphaFar, canvas.AlphaMid, canvas.AlphaNear)
|
|
sh.Update(c, 2, Activity{TimeOfDay: tc.tod})
|
|
if got := sh.night(); got != tc.night {
|
|
t.Errorf("tod %.3f: night=%v, want %v (zenith %v)", tc.tod, got, tc.night, sh.pal.SkyTop)
|
|
}
|
|
}
|
|
}
|