-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmancala_test.go
127 lines (113 loc) · 3.3 KB
/
mancala_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package main
import (
"math"
"testing"
)
func TestMakeMove_1(t *testing.T) {
board := [14]uint8{4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 0}
newBoard := MakeMove(true, board, 3)
resultBoard := [14]uint8{4, 4, 4, 0, 5, 5, 1, 5, 4, 4, 4, 4, 4, 0}
if newBoard != resultBoard {
t.Error(board)
t.Error(newBoard)
t.Error(resultBoard)
}
}
func TestMakeMove_2(t *testing.T) {
board := [14]uint8{4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 0}
newBoard := MakeMove(true, board, 2)
resultBoard := [14]uint8{4, 4, 0, 5, 5, 5, 1, 4, 4, 4, 4, 4, 4, 0}
if newBoard != resultBoard {
t.Error(board)
t.Error(newBoard)
t.Error(resultBoard)
}
}
func TestMakeMove_3(t *testing.T) {
board := [14]uint8{13, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 0}
newBoard := MakeMove(true, board, 0)
resultBoard := [14]uint8{6, 5, 5, 5, 5, 5, 1, 5, 5, 5, 5, 5, 0, 0}
if newBoard != resultBoard {
t.Error(board)
t.Error(newBoard)
t.Error(resultBoard)
}
}
func TestMakeMove_4(t *testing.T) {
board := [14]uint8{14, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 0}
newBoard := MakeMove(true, board, 0)
resultBoard := [14]uint8{1, 6, 5, 5, 5, 5, 1, 5, 5, 5, 5, 5, 5, 0}
if newBoard != resultBoard {
t.Error(board)
t.Error(newBoard)
t.Error(resultBoard)
}
}
func TestMakeMove_5(t *testing.T) {
board := [14]uint8{4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 0}
newBoard := MakeMove(false, board, 7)
resultBoard := [14]uint8{4, 4, 4, 4, 4, 4, 0, 0, 5, 5, 5, 5, 4, 0}
if newBoard != resultBoard {
t.Error(board)
t.Error(newBoard)
t.Error(resultBoard)
}
}
func TestMakeMove_6(t *testing.T) {
board := [14]uint8{4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 0}
newBoard := MakeMove(false, board, 9)
resultBoard := [14]uint8{4, 4, 4, 4, 4, 4, 0, 4, 4, 0, 5, 5, 5, 1}
if newBoard != resultBoard {
t.Error(board)
t.Error(newBoard)
t.Error(resultBoard)
}
}
func TestMakeMove_7(t *testing.T) {
board := [14]uint8{4, 4, 4, 4, 4, 4, 0, 13, 4, 4, 4, 4, 4, 0}
newBoard := MakeMove(false, board, 7)
resultBoard := [14]uint8{5, 5, 5, 5, 5, 0, 0, 6, 5, 5, 5, 5, 5, 1}
if newBoard != resultBoard {
t.Error(board)
t.Error(newBoard)
t.Error(resultBoard)
}
}
func TestMakeMove_8(t *testing.T) {
board := [14]uint8{4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 1, 0}
newBoard := MakeMove(false, board, 12)
resultBoard := [14]uint8{0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 1}
if newBoard != resultBoard {
t.Error(board)
t.Error(newBoard)
t.Error(resultBoard)
}
}
func TestMakeMove_9(t *testing.T) {
board := [14]uint8{0, 0, 0, 0, 0, 1, 0, 4, 4, 4, 4, 4, 4, 0}
newBoard := MakeMove(true, board, 5)
resultBoard := [14]uint8{0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 24}
if newBoard != resultBoard {
t.Error(board)
t.Error(newBoard)
t.Error(resultBoard)
}
}
func TestAlphaBeta(t *testing.T) {
board := [14]uint8{4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 0}
AlphaBeta(true, board, math.MinInt32, math.MaxInt32, 11)
}
func TestDetermineMove(t *testing.T) {
board := [14]uint8{4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 0}
DetermineMove(true, board, 10)
}
func BenchmarkAlphaBeta(b *testing.B) {
board := [14]uint8{4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 0}
b.ResetTimer()
AlphaBeta(true, board, math.MinInt32, math.MaxInt32, 11)
}
func BenchmarkDetermineMove(b *testing.B) {
board := [14]uint8{4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 0}
b.ResetTimer()
DetermineMove(true, board, 10)
}