Skip to content

Commit 5faf4e1

Browse files
authored
Merge pull request #448 from domino14/claude/fix-vertical-play-bug-thF4n
Fix analyzer marking vertical opening plays as mistakes
2 parents a77435c + 79345f7 commit 5faf4e1

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)