Skip to content

Commit e689fdd

Browse files
committed
Make use of local vars plays and wins.
Instead of doing an attribute lookup each time.
1 parent 3dffdd3 commit e689fdd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

mcts/uct.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ def run_simulation(self):
122122

123123
# `player` here and below refers to the player
124124
# who moved into that particular state.
125-
if expand and (player, state) not in self.plays:
125+
if expand and (player, state) not in plays:
126126
expand = False
127-
self.plays[(player, state)] = 0
128-
self.wins[(player, state)] = 0
127+
plays[(player, state)] = 0
128+
wins[(player, state)] = 0
129129
if t > self.max_depth:
130130
self.max_depth = t
131131

@@ -137,8 +137,8 @@ def run_simulation(self):
137137
break
138138

139139
for player, state in visited_states:
140-
if (player, state) not in self.plays:
140+
if (player, state) not in plays:
141141
continue
142-
self.plays[(player, state)] += 1
142+
plays[(player, state)] += 1
143143
if player == winner:
144-
self.wins[(player, state)] += 1
144+
wins[(player, state)] += 1

0 commit comments

Comments
 (0)