-
Notifications
You must be signed in to change notification settings - Fork 4
/
score.py
39 lines (33 loc) · 845 Bytes
/
score.py
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
from GoGame.GoSimulator import GoSimulator
import numpy as np
from Shared.Consts import BLACK, WHITE
game = GoSimulator(5)
player = WHITE
boards = np.array([
[[ 0, -1, -1, -1, 0],
[-1, 0, -1, -1, 0],
[-1, -1, -1, -1, 1],
[-1, 0, -1, 0, -1],
[-1, -1, -1, -1, -1]],
[[ 0, -1, -1, -1, 0],
[-1, 0, -1, -1, 0],
[-1, -1, -1, -1, 1],
[-1, 0, -1, 0, -1],
[-1, -1, -1, -1, -1]]
])
class StubModel:
def eval(self, boards, player):
game.set_board_from_prev_boards(boards, player)
black_lead = game.black_score_lead()
if black_lead == 0:
V = 0
elif player == BLACK:
V = (black_lead > 0)*2 - 1
else:
V = (black_lead < 0)*2 - 1
P = np.ones(26)
return P, V
model = StubModel()
_, V = model.eval(boards, player)
print(player)
print(V)