Skip to content

Commit

Permalink
Abstract is_stochastic from Match and Moran
Browse files Browse the repository at this point in the history
  • Loading branch information
marcharper committed Apr 13, 2016
1 parent 951a6cd commit d0c88cb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions axelrod/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
C, D = Actions.C, Actions.D


def is_stochastic(players, noise):
"""Determines if a match is stochastic -- true if there is noise or if any
of the players involved is stochastic."""
return (
self._noise or
any(p.classifier['stochastic'] for p in self.players)
)

class Match(object):

def __init__(self, players, turns, deterministic_cache=None, noise=0):
Expand Down Expand Up @@ -38,10 +46,7 @@ def _stochastic(self):
A boolean to show whether a match between two players would be
stochastic
"""
return (
self._noise or
any(p.classifier['stochastic'] for p in self.players)
)
return is_stochastic(self.players, self._noise)

@property
def _cache_update_required(self):
Expand Down

0 comments on commit d0c88cb

Please sign in to comment.