コード例 #1
0
 def __init__(self, players, turns, repetitions, outcome,
              with_morality=True):
     """
     Args:
         players (list): a list of player objects.
         turns (int): the number of turns per interaction.
         repetitions (int): the number of time the round robin was repeated.
         outcome (dict): returned from the RoundRobin class and containing
             various sets of results for processing by this class.
         with_morality (bool): a flag to determine whether morality metrics
             should be calculated.
     """
     self.players = players
     self.nplayers = len(players)
     self.turns = turns
     self.repetitions = repetitions
     self.outcome = outcome
     self.results = self._results(outcome)
     self.scores = None
     self.normalised_scores = None
     self.ranking = None
     self.ranked_names = None
     self.payoff_matrix = None
     self.wins = None
     self.cooperation = None
     self.normalised_cooperation = None
     self.vengeful_cooperation = None
     self.cooperating_rating = None
     self.good_partner_matrix = None
     self.good_partner_rating = None
     self.eigenjesus_rating = None
     self.eigenmoses_rating = None
     if 'payoff' in self.results:
         self.scores = ap.scores(
             self.results['payoff'], len(players), repetitions)
         self.normalised_scores = ap.normalised_scores(
             self.scores, len(players), turns)
         self.ranking = ap.ranking(self.scores, len(players))
         self.ranked_names = ap.ranked_names(players, self.ranking)
         self.payoff_matrix, self.payoff_stddevs = (ap.normalised_payoff(
             self.results['payoff'], turns, repetitions))
         self.wins = ap.wins(
             self.results['payoff'], len(players), repetitions)
     if 'cooperation' in self.results and with_morality:
         self.cooperation = ac.cooperation_matrix(
             self.results['cooperation'])
         self.normalised_cooperation = ac.normalised_cooperation(
             self.cooperation, turns, repetitions)
         self.vengeful_cooperation = ac.vengeful_cooperation(
             self.normalised_cooperation)
         self.cooperating_rating = ac.cooperating_rating(
             self.cooperation, len(players), turns, repetitions)
         self.good_partner_matrix = ac.good_partner_matrix(
             self.results['cooperation'], len(players), repetitions)
         self.good_partner_rating = ac.good_partner_rating(
             self.good_partner_matrix, len(players), repetitions)
         self.eigenjesus_rating = ac.eigenvector(self.normalised_cooperation)
         self.eigenmoses_rating = ac.eigenvector(self.vengeful_cooperation)
コード例 #2
0
 def test_cooperation_matrix(self):
     cooperation_matrix = ac.cooperation_matrix(
         self.expected_cooperation_results
     )
     self.assertEqual(cooperation_matrix, self.expected_cooperation_matrix)
コード例 #3
0
ファイル: test_cooperation.py プロジェクト: cc13ny/Axelrod
 def test_cooperation_matrix(self):
     cooperation_matrix = ac.cooperation_matrix(self.interactions)
     self.assertEqual(cooperation_matrix, self.expected_cooperation_matrix)
コード例 #4
0
 def test_cooperation_matrix(self):
     cooperation_matrix = ac.cooperation_matrix(self.interactions)
     self.assertEqual(cooperation_matrix, self.expected_cooperation_matrix)