@@ -128,7 +128,8 @@ def _cache_update_required(self):
128
128
A boolean to show whether the deterministic cache should be updated.
129
129
"""
130
130
return (
131
- not self .noise
131
+ not self ._stochastic
132
+ and not self .noise
132
133
and self ._cache .mutable
133
134
and not (any (Classifiers ["stochastic" ](p ) for p in self .players ))
134
135
)
@@ -180,28 +181,29 @@ def play(self):
180
181
turns = self .turns
181
182
cache_key = (self .players [0 ], self .players [1 ])
182
183
183
- if self ._stochastic or not self ._cached_enough_turns (cache_key , turns ):
184
- for p in self .players :
185
- if self .reset :
186
- p .reset ()
187
- p .set_match_attributes (** self .match_attributes )
188
- # Generate a random seed for the player, if stochastic
189
- if Classifiers ["stochastic" ](p ):
190
- p .set_seed (self ._random .random_seed_int ())
191
- result = []
192
- for _ in range (turns ):
193
- plays = self .simultaneous_play (
194
- self .players [0 ], self .players [1 ], self .noise
195
- )
196
- result .append (plays )
197
-
198
- if self ._cache_update_required :
199
- self ._cache [cache_key ] = result
200
- else :
201
- result = self ._cache [cache_key ][:turns ]
184
+ if self ._cached_enough_turns (cache_key , turns ):
185
+ self .result = self ._cache [cache_key ][:turns ]
186
+ return self .result
187
+
188
+ for p in self .players :
189
+ if self .reset :
190
+ p .reset ()
191
+ p .set_match_attributes (** self .match_attributes )
192
+ # Generate a random seed for the player, if stochastic
193
+ if Classifiers ["stochastic" ](p ):
194
+ p .set_seed (self ._random .random_seed_int ())
195
+ result = []
196
+ for _ in range (turns ):
197
+ plays = self .simultaneous_play (
198
+ self .players [0 ], self .players [1 ], self .noise
199
+ )
200
+ result .append (plays )
201
+
202
+ if self ._cache_update_required :
203
+ self ._cache [cache_key ] = result
202
204
203
205
self .result = result
204
- return result
206
+ return self . result
205
207
206
208
def scores (self ):
207
209
"""Returns the scores of the previous Match plays."""
0 commit comments