Esempio n. 1
0
    def update_histories(self, coplay):
        super().update_histories(coplay)
        self._update_scores(coplay)

    def meta_strategy(self, results, opponent):
        # Choice an action based on the collection of scores
        bestscore = max(self.scores)
        beststrategies = [
            i for (i, score) in enumerate(self.scores) if score == bestscore
        ]
        bestproposals = [results[i] for i in beststrategies]
        bestresult = C if C in bestproposals else D
        return bestresult


NiceMetaWinner = NiceTransformer()(MetaWinner)


class MetaWinnerEnsemble(MetaWinner):
    """A variant of MetaWinner that chooses one of the top scoring strategies
    at random against each opponent. Note this strategy is always stochastic
    regardless of the team.

    Names:

    - Meta Winner Ensemble: Original name by Marc Harper
    """

    name = "Meta Winner Ensemble"

    def meta_strategy(self, results, opponent):
Esempio n. 2
0
        self._update_scores(opponent)
        # Choice an action based on the collection of scores
        bestscore = max(self.scores)
        beststrategies = [
            i for (i, score) in enumerate(self.scores) if score == bestscore
        ]
        bestproposals = [results[i] for i in beststrategies]
        bestresult = C if C in bestproposals else D
        return bestresult

    def reset(self):
        super().reset()
        self.scores = [0] * len(self.team)


NiceMetaWinner = NiceTransformer()(MetaWinner)
NiceMetaWinner.name = "Nice Meta Winner"


class MetaWinnerEnsemble(MetaWinner):
    """A variant of MetaWinner that chooses one of the top scoring strategies
    at random against each opponent. Note this strategy is always stochastic
    regardless of the team.

    Names:

    Meta Winner Ensemble: Original name by Marc Harper
    """

    name = "Meta Winner Ensemble"