@@ -130,7 +130,8 @@ def _cache_update_required(self):
130130 A boolean to show whether the deterministic cache should be updated.
131131 """
132132 return (
133- not self .noise
133+ not self .is_stochastic
134+ and not self .noise
134135 and self ._cache .mutable
135136 and not (any (Classifiers ["stochastic" ](p ) for p in self .players ))
136137 )
@@ -182,25 +183,25 @@ def play(self):
182183 turns = self .turns
183184 cache_key = (self .players [0 ], self .players [1 ])
184185
185- if self ._stochastic or not self . _cached_enough_turns (cache_key , turns ):
186- for p in self .players :
187- if self . reset :
188- p . reset ()
189- p . set_match_attributes ( ** self .match_attributes )
190- # Generate a random seed for the player, if stochastic
191- if Classifiers [ "stochastic" ]( p ):
192- p . set_seed ( self . _random . random_seed_int ())
193- result = []
194- for _ in range ( turns ):
195- plays = self . simultaneous_play (
196- self . players [ 0 ], self . players [ 1 ], self . noise
197- )
198- result . append ( plays )
199-
200- if self . _cache_update_required :
201- self . _cache [ cache_key ] = result
202- else :
203- result = self ._cache [cache_key ][: turns ]
186+ if self ._cached_enough_turns (cache_key , turns ):
187+ return self ._cache [ cache_key ][: turns ]
188+
189+ for p in self . players :
190+ if self .reset :
191+ p . reset ()
192+ p . set_match_attributes ( ** self . match_attributes )
193+ # Generate a random seed for the player, if stochastic
194+ if Classifiers [ "stochastic" ]( p ):
195+ p . set_seed ( self . _random . random_seed_int ())
196+ result = []
197+ for _ in range ( turns ):
198+ plays = self . simultaneous_play (
199+ self . players [ 0 ], self . players [ 1 ], self . noise
200+ )
201+ result . append ( plays )
202+
203+ if self . _cache_update_required :
204+ self ._cache [cache_key ] = result
204205
205206 self .result = result
206207 return result
0 commit comments