-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer_test.go
53 lines (40 loc) · 1.23 KB
/
player_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
package reversi
import (
"fmt"
"testing"
)
func TestComputerPlayer(t *testing.T) {
board := NewBoard()
player1 := NewComputerPlayer(STONE_BLACK)
player2 := NewComputerPlayer(STONE_WHITE)
a := func(b *Board, stone int) int {
restTurn := b.CountStone(STONE_BLANK)
mnum, enum := b.CountStone(stone), b.CountStone(-stone)
if restTurn < 5 {
return mnum - enum
}
mmovables := b.CalcMovable(stone)
emovables := b.CalcMovable(-stone)
return (mnum - enum) + 6*(len(mmovables)-len(emovables))
}
b := func(b *Board, stone int) int {
restTurn := b.CountStone(STONE_BLANK)
if restTurn < 5 {
mnum, enum := b.CountStone(stone), b.CountStone(-stone)
return mnum - enum
}
return 67*b.CountMobility(stone) - 13*b.CountLiverty(stone)*101*b.CountStable(stone) - 308*b.CountWindow(stone) - 552*b.CountCornerStone(stone)
}
var pos Pos
for !board.CheckGameover() {
pos = player1.Think(*board, a, 6)
board.Move(pos.Index, STONE_BLACK)
fmt.Println(pos, board.CountStone(STONE_BLACK), board.CountStone(STONE_WHITE))
pos = player2.Think(*board, b, 6)
board.Move(pos.Index, STONE_WHITE)
fmt.Println(pos, board.CountStone(STONE_BLACK), board.CountStone(STONE_WHITE))
}
if pos.Index < 0 {
t.Errorf("Failed!")
}
}