<commit_before>"""Test for the go by majority strategy."""

import axelrod

from .test_player import TestPlayer

C, D = 'C', 'D'


class TestGoByMajority(TestPlayer):

    name = "Soft Go By Majority"
    player = axelrod.GoByMajority
    stochastic = False

    def test_initial_strategy(self):
        """Starts by cooperating """
        self.first_play_test(C)

    def test_strategy(self):
        """
        If opponent cooperates at least as often as they defect then the player cooperates
        """
        self.responses_test([C, D, D, D], [D, D, C, C], [C])
        self.responses_test([C, C, D, D, C], [D, D, C, C, D], [D])

def factory_TestGoByRecentMajority(L):<commit_msg>Test for Hard vs. Soft in GoByMajority<commit_after>"""Test for the go by majority strategy."""

import axelrod

from .test_player import TestPlayer

C, D = 'C', 'D'


class TestGoByMajority(TestPlayer):

    name = "Soft Go By Majority"
    player = axelrod.GoByMajority
    stochastic = False

    def test_initial_strategy(self):
        """Starts by cooperating """
        self.first_play_test(C)

    def test_strategy(self):
        """
        If opponent cooperates at least as often as they defect then the player cooperates
        """
        self.responses_test([C, D, D, D], [D, D, C, C], [C])
        self.responses_test([C, C, D, D, C], [D, D, C, C, D], [D])

    def test_repr(self):
        player = self.player(soft=True)
        name = str(player)
        self.assertEqual(name, "Soft Go By Majority")
        player = self.player(soft=False)
        name = str(player)
        self.assertEqual(name, "Hard Go By Majority")

def factory_TestGoByRecentMajority(L):
{'fraction_non_alphanumeric': 0.12320574162679426, 'fraction_numerical': 0.0, 'mean_word_length': 2.918032786885246, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7135825', 'n_tokens_mistral': 569, 'n_tokens_neox': 544, 'n_words': 169}