Skip to content

Commit d18fb56

Browse files
committed
Also include the AI name in the extras
and make sure that the extras are always included, even when short-circuiting.
1 parent dd7ef2b commit d18fb56

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mcts/uct.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def get_action(self):
4646
# current game state and return it.
4747

4848
self.max_depth = 0
49-
self.data = {'C': self.C, 'max_actions': self.max_actions}
49+
self.data = {'C': self.C, 'max_actions': self.max_actions, 'name': self.name}
5050
self.stats.clear()
5151

5252
state = self.history[-1]
@@ -55,12 +55,12 @@ def get_action(self):
5555

5656
# Bail out early if there is no real choice to be made.
5757
if not legal:
58-
return {'type': 'action', 'message': None, 'extras': {}}
58+
return {'type': 'action', 'message': None, 'extras': self.data.copy()}
5959
if len(legal) == 1:
6060
return {
6161
'type': 'action',
6262
'message': self.board.to_json_action(legal[0]),
63-
'extras': {},
63+
'extras': self.data.copy(),
6464
}
6565

6666
games = 0
@@ -147,6 +147,7 @@ def run_simulation(self):
147147

148148

149149
class UCTWins(UCT):
150+
name = "jrb.mcts.uct"
150151
action_template = "{action}: {percent:.2f}% ({wins} / {plays})"
151152

152153
def __init__(self, board, **kwargs):
@@ -167,6 +168,7 @@ def calculate_action_values(self, history, player, legal):
167168

168169

169170
class UCTValues(UCT):
171+
name = "jrb.mcts.uctv"
170172
action_template = "{action}: {average:.1f} ({sum} / {plays})"
171173

172174
def __init__(self, board, **kwargs):

0 commit comments

Comments
 (0)