Skip to content

Commit 79345f7

Browse files
committed
Fix analyzer marking vertical opening plays as mistakes
On an empty board, the move generator only produces horizontal plays; vertical openers are transpositionally equivalent. The simmer's AvoidPruningMoves already handled this (checking transpositions when board is empty), but analyzeWithSim compared results using Equals(playedMove, false, true) — never checking transpositions. This caused vertical first plays to not match their horizontal equivalent in the sim results, resulting in PlayedWinProb=0 and a spurious large mistake. Pass g.Board().IsEmpty() as the transposition flag when comparing moves in the sim results, consistent with how AvoidPruningMoves works. Fixes #447 https://claude.ai/code/session_01DWqqGkbTUn3YN36qThU6Ak
1 parent a77435c commit 79345f7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

gameanalysis/analyzer.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,14 +538,20 @@ func (a *Analyzer) analyzeWithSim(ctx context.Context, g *game.Game, analysis *T
538538
return errors.New("simulation produced no results")
539539
}
540540

541+
// On an empty board, the move generator only produces horizontal plays;
542+
// vertical first plays are transpositions. We must check transpositions
543+
// when comparing moves so a vertical opener is matched to its horizontal
544+
// equivalent in the sim results.
545+
checkTrans := g.Board().IsEmpty()
546+
541547
// Find optimal move (highest win prob)
542548
analysis.OptimalMove = simmedPlays[0].Move()
543549
analysis.OptimalWinProb = simmedPlays[0].WinProb()
544550

545551
// Find played move in results
546552
playedFound := false
547553
for _, result := range simmedPlays {
548-
if result.Move().Equals(analysis.PlayedMove, false, true) {
554+
if result.Move().Equals(analysis.PlayedMove, checkTrans, true) {
549555
analysis.PlayedWinProb = result.WinProb()
550556
playedFound = true
551557
break
@@ -559,7 +565,7 @@ func (a *Analyzer) analyzeWithSim(ctx context.Context, g *game.Game, analysis *T
559565
}
560566

561567
analysis.WinProbLoss = analysis.OptimalWinProb - analysis.PlayedWinProb
562-
analysis.WasOptimal = analysis.OptimalMove.Equals(analysis.PlayedMove, false, true)
568+
analysis.WasOptimal = analysis.OptimalMove.Equals(analysis.PlayedMove, checkTrans, true)
563569

564570
// Set bingo flags
565571
analysis.OptimalIsBingo = isBingo(analysis.OptimalMove)

0 commit comments

Comments
 (0)