Example #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:
            payoff = self.results['payoff']
            self.scores = ap.scores(payoff)
            self.normalised_scores = ap.normalised_scores(self.scores, turns)
            self.ranking = ap.ranking(self.scores)
            self.ranked_names = ap.ranked_names(players, self.ranking)
            self.payoff_matrix, self.payoff_stddevs = (ap.normalised_payoff(
                payoff, turns))
            self.wins = ap.wins(payoff)
            self.payoff_diffs_means = ap.payoff_diffs_means(payoff, turns)
            self.score_diffs = ap.score_diffs(payoff, turns)

        if 'cooperation' in self.results and with_morality:
            self.cooperation = ac.cooperation(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)
Example #2
0
 def test_normalised_scores(self):
     scores = ap.normalised_scores(self.expected_scores, 5)
     self.assertEqual(scores, self.expected_normalised_scores)
Example #3
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:
            payoff = self.results['payoff']
            self.scores = ap.scores(payoff)
            self.normalised_scores = ap.normalised_scores(self.scores, turns)
            self.ranking = ap.ranking(self.scores)
            self.ranked_names = ap.ranked_names(players, self.ranking)
            self.payoff_matrix, self.payoff_stddevs = (ap.normalised_payoff(
                payoff, turns))
            self.wins = ap.wins(payoff)
            self.payoff_diffs_means = ap.payoff_diffs_means(payoff, turns)
            self.score_diffs = ap.score_diffs(payoff, turns)

        if 'cooperation' in self.results and with_morality:
            self.cooperation = ac.cooperation(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)
Example #4
0
 def test_normalised_scores(self):
     scores = ap.normalised_scores(self.expected_scores, 5)
     self.assertEqual(scores, self.expected_normalised_scores)