diff --git a/board.go b/board.go index 343dc0a..c2c1acd 100644 --- a/board.go +++ b/board.go @@ -8,9 +8,9 @@ import ( ) var ( - WeightBlot = 1.0 - WeightHit = -1.0 - WeightOppScore = -3.0 + WeightBlot = 2.0 + WeightHit = -2.0 + WeightOppScore = -1.0 ) const ( @@ -258,6 +258,7 @@ func (b Board) Available(player int) [][]int { return moves } +// TODO no player argument needed func (b Board) Past(player int) bool { if b[SpaceBarPlayer] != 0 || b[SpaceBarOpponent] != 0 { return false @@ -306,13 +307,14 @@ func (b Board) Pips(player int) int { } func (b Board) Blots(player int) int { + o := opponent(player) var pips int for space := 1; space < 25; space++ { checkers := b.Checkers(player, space) if checkers != 1 { continue } - pips += int(checkers) * spaceValue(player, space) + pips += int(checkers) * spaceValue(o, space) } return pips } @@ -446,7 +448,7 @@ func (b Board) Analyze(player int, available [][]int) []*Analysis { } available := bc.Available(2) a := &Analysis{ - Past: b.Past(2), + Past: a.Past, } w.Add(len(available)) queueAnalysis(a, w, bc, 2, available, nil, &[][][]int{}, &oppResults[i], oppResultMutex) diff --git a/board_test.go b/board_test.go index d5194a6..63d4bdc 100644 --- a/board_test.go +++ b/board_test.go @@ -78,6 +78,40 @@ func TestPast(t *testing.T) { } } +func TestBlots(t *testing.T) { + b := NewBoard() + got, expected := b.Blots(1), 0 + if got != expected { + t.Errorf("unexpected past value: expected %v: got %v", expected, got) + } + got, expected = b.Blots(2), 0 + if got != expected { + t.Errorf("unexpected past value: expected %v: got %v", expected, got) + } + + b = b.Move(24, 23, 1) + + got, expected = b.Blots(1), 3 + if got != expected { + t.Errorf("unexpected past value: expected %v: got %v", expected, got) + } + got, expected = b.Blots(2), 0 + if got != expected { + t.Errorf("unexpected past value: expected %v: got %v", expected, got) + } + + b = b.Move(1, 2, 2) + + got, expected = b.Blots(1), 3 + if got != expected { + t.Errorf("unexpected past value: expected %v: got %v", expected, got) + } + got, expected = b.Blots(2), 3 + if got != expected { + t.Errorf("unexpected past value: expected %v: got %v", expected, got) + } +} + func BenchmarkAvailable(b *testing.B) { type testCase struct { roll1, roll2, roll3, roll4 int8