def dump_state(state, children=None, move=None):
if children is None:
children = []
if state.current_player == 0:
overall_percent = (sum(child.wins_by_player[0]
for child in children) / 1000.0) * 100
else:
overall_percent = None
children = {
child.move: {'ucb': child.ucb1(child.parent.current_player),
'visits': child.visits,
'wins': child.wins_by_player[child.parent.current_player]}
for child in children}
print(dumps({'state': state.__dict__,
'children': children,
'overall_percent': overall_percent,
'error': None},
cls=GameEncoder))
stdout.flush()
评论列表
文章目录