Format moves when printing analysis
This commit is contained in:
parent
2c201e72dd
commit
d51931e431
1 changed files with 16 additions and 2 deletions
|
@ -478,9 +478,9 @@ func (c *Client) HandleEvents() {
|
|||
|
||||
const padding = 3
|
||||
w := tabwriter.NewWriter(os.Stderr, 0, 0, padding, ' ', 0)
|
||||
fmt.Fprintln(w, "Moves\tScore\tPlayer Score\tPips\tBlots\tHits\tOpponent Score\tPips\tBlots\tHits\t")
|
||||
fmt.Fprintln(w, "Moves\tScore\tP. Score\tPips\tBlots\tHits\tO. Score\tPips\tBlots\tHits\t")
|
||||
for _, r := range c.analysis {
|
||||
fmt.Fprintf(w, "%s\t%.2f\t%.2f\t%d\t%d\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t\n", fmt.Sprint(r.Moves), r.Score, r.PlayerScore, r.Pips, r.Blots, r.Hits, r.OppScore, r.OppPips, r.OppBlots, r.OppHits)
|
||||
fmt.Fprintf(w, "%s\t%.2f\t%.2f\t%d\t%d\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t\n", printMoves(r.Moves), r.Score, r.PlayerScore, r.Pips, r.Blots, r.Hits, r.OppScore, r.OppPips, r.OppBlots, r.OppHits)
|
||||
}
|
||||
w.Flush()
|
||||
log.Println("==========")
|
||||
|
@ -594,6 +594,20 @@ func TabulaBoard(b []int8) tabula.Board {
|
|||
return tabula.Board{b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8], b[9], b[10], b[11], b[12], b[13], b[14], b[15], b[16], b[17], b[18], b[19], b[20], b[21], b[22], b[23], b[24], b[25], b[26], b[27], roll1, roll2, roll3, roll4, entered1, entered2, Game.Variant}
|
||||
}
|
||||
|
||||
func printMoves(moves [4][2]int8) []byte {
|
||||
var b []byte
|
||||
for i := 0; i < 4; i++ {
|
||||
log.Println(i)
|
||||
if moves[i][0] == 0 && moves[i][1] == 0 {
|
||||
break
|
||||
} else if i != 0 {
|
||||
b = append(b, ' ')
|
||||
}
|
||||
b = append(b, []byte(fmt.Sprintf("[%02d %02d]", moves[i][0], moves[i][1]))...)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func randInt(max int) int {
|
||||
i, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue