From 78fbe9d9b17a04bfd6662f9a58d7ba83502a5d79 Mon Sep 17 00:00:00 2001 From: Harry Witte Date: Tue, 17 Nov 2026 10:30:19 -0500 Subject: [PATCH] show analysis judgments on the board After computer analysis, the move shown gets its ?! ? or ?? as a badge on the square it went to, the way studies show their annotations. The graph's title is shortened to "Stockfish analysis" so it fits a narrow sidebar. --- pkg/analysis.go | 5 +++++ pkg/analysis_test.go | 21 ++++++++++++++++++++- pkg/analysis_view.go | 18 ++++++++++++++---- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/pkg/analysis.go b/pkg/analysis.go index 18a93c6..fa856ad 100644 --- a/pkg/analysis.go +++ b/pkg/analysis.go @@ -48,6 +48,11 @@ func (j judgment) plural() string { return [...]string{"", "Inaccuracies", "Mistakes", "Blunders"}[j] } +// nag is the judgment's annotation symbol (NAG) for the board: ?! ? ??. +func (j judgment) nag() moveGlyph { + return [...]moveGlyph{0, 6, 2, 4}[j] +} + // colour is the tag the move list and summary use for a judgment (Lichess's // colours). func (j judgment) colour() string { diff --git a/pkg/analysis_test.go b/pkg/analysis_test.go index ca1496b..b20e3d0 100644 --- a/pkg/analysis_test.go +++ b/pkg/analysis_test.go @@ -161,6 +161,13 @@ func TestAnalysisPanel(t *testing.T) { t.Errorf("table has no %q:\n%s", want, table) } } + b := Root.pgame.postGame.Board + b.mu.Lock() + sq, g := b.glyphSq, b.glyph + b.mu.Unlock() + if sq != chess.G5 || g.text() != "??" { + t.Errorf("board glyph %v on %v, want ?? on g5", g.text(), sq) + } if !strings.Contains(p.history.GetText(true), "Ng5??") { t.Errorf("move list not marked:\n%s", p.history.GetText(true)) } @@ -169,5 +176,17 @@ func TestAnalysisPanel(t *testing.T) { t.Errorf("graph %d rows, want 9", gh) } }) - onUI(func() { gotoWelcome() }) + // a move without a judgment: no symbol + onUI(func() { Root.pgame.postGame.Board.ShowPly(2) }) + waitFor(t, "the note for e5", func() bool { return strings.Contains(p.note.GetText(true), "1… e5") }) + onUI(func() { + b := Root.pgame.postGame.Board + b.mu.Lock() + g := b.glyph + b.mu.Unlock() + if g != 0 { + t.Errorf("e5 shows %v on the board", g.text()) + } + gotoWelcome() + }) } diff --git a/pkg/analysis_view.go b/pkg/analysis_view.go index e685923..2456b9b 100644 --- a/pkg/analysis_view.go +++ b/pkg/analysis_view.go @@ -240,6 +240,7 @@ func (p *analysisPanel) reset() { for _, it := range []cv.Primitive{p.graph, p.table, p.note} { p.side.ResizeItem(it, 0, 0) } + p.board.SetGlyph(chess.NoSquare, 0) } // start analyses the game with the local Stockfish; status reports @@ -289,7 +290,7 @@ func (p *analysisPanel) start(positions []*chess.Position, moves []*chess.Move, // finished shows the numbers once every position is analysed. func (p *analysisPanel) finished() { a := p.a - p.setT("Computer analysis · Stockfish") + p.setT("Stockfish analysis") // short: the sidebar can be 30 wide p.table.SetText(analysisTable(a)) p.side.ResizeItem(p.table, strings.Count(p.table.GetText(false), "\n"), 0) p.side.ResizeItem(p.note, 2, 0) @@ -300,9 +301,18 @@ func (p *analysisPanel) finished() { p.shown(ply) } -// shown updates the note for the move the board is showing. +// shown updates the note for the move the board is showing, and marks the +// square it went to with its ?! ? or ?? (as studies show their symbols). func (p *analysisPanel) shown(ply int) { - if p.a != nil { - p.note.SetText(moveNote(p.a, ply)) + if p.a == nil { + return + } + p.note.SetText(moveNote(p.a, ply)) + if p.a.complete() && ply >= 1 && ply <= len(p.a.moves) { + if j := p.a.judged[ply-1]; j != judgeNone { + p.board.SetGlyph(p.a.moves[ply-1].S2(), j.nag()) + return + } } + p.board.SetGlyph(chess.NoSquare, 0) }