diff --git a/analysis.go b/analysis.go index b64d97a..c2dd15c 100644 --- a/analysis.go +++ b/analysis.go @@ -25,5 +25,5 @@ type Analysis struct { } func (a *Analysis) String() string { - return fmt.Sprintf("Moves: %s Score: %.2f - Score: %.2f Pips: %d Blots: %d Hits: %d / Score: %.2f Pips: %.2f Blots: %.2f Hits: %.2f", fmt.Sprint(a.Moves), a.Score, a.PlayerScore, a.Pips, a.Blots, a.Hits, a.OppScore, a.OppPips, a.OppBlots, a.OppHits) + return fmt.Sprintf("Moves: %s Score: %.2f - Score: %.2f Pips: %d Blots: %d Hits: %d / Score: %.2f Pips: %.2f Blots: %.2f Hits: %.2f Past: %v", fmt.Sprint(a.Moves), a.Score, a.PlayerScore, a.Pips, a.Blots, a.Hits, a.OppScore, a.OppPips, a.OppBlots, a.OppHits, a.past) } diff --git a/board.go b/board.go index 935998e..15f0873 100644 --- a/board.go +++ b/board.go @@ -2,6 +2,7 @@ package tabula import ( "log" + "math" "sort" "sync" ) @@ -500,11 +501,15 @@ func (b Board) Analyze(player int, available [][]int) []*Analysis { oppScore += r.PlayerScore count++ } + score := result[i].PlayerScore + if !math.IsNaN(oppScore) { + score += result[i].OppScore * WeightOppScore + } result[i].OppPips = (oppPips / count) result[i].OppBlots = (oppBlots / count) result[i].OppHits = (oppHits / count) result[i].OppScore = (oppScore / count) - result[i].Score = result[i].PlayerScore + result[i].OppScore*WeightOppScore + result[i].Score = score } } sort.Slice(result, func(i, j int) bool {