Fix NaN error
This commit is contained in:
parent
bc5fe93e6a
commit
2a8f1687c4
2 changed files with 7 additions and 2 deletions
|
@ -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)
|
||||
}
|
||||
|
|
7
board.go
7
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 {
|
||||
|
|
Loading…
Reference in a new issue