diff --git a/axelrod/compute_finite_state_machine_memory.py b/axelrod/compute_finite_state_machine_memory.py index b46ad58db..686698c5a 100644 --- a/axelrod/compute_finite_state_machine_memory.py +++ b/axelrod/compute_finite_state_machine_memory.py @@ -113,7 +113,10 @@ def get_accessible_transitions( if trans.state in accessible_states: accessible_transitions[ (trans.state, trans.last_opponent_action) - ] = (trans.next_state, trans.next_action) + ] = ( + trans.next_state, + trans.next_action, + ) return accessible_transitions diff --git a/axelrod/fingerprint.py b/axelrod/fingerprint.py index 638707f57..69e880cbf 100644 --- a/axelrod/fingerprint.py +++ b/axelrod/fingerprint.py @@ -42,7 +42,7 @@ def _create_points(step: float, progress_bar: bool = True) -> List[Point]: num = int((1 / step) // 1) + 1 if progress_bar: - p_bar = tqdm.tqdm(total=num ** 2, desc="Generating points") + p_bar = tqdm.tqdm(total=num**2, desc="Generating points") points = [] for x in np.linspace(0, 1, num): diff --git a/axelrod/random_.py b/axelrod/random_.py index 73289ff8f..bafb84a5a 100644 --- a/axelrod/random_.py +++ b/axelrod/random_.py @@ -29,7 +29,7 @@ def randint(self, *args, **kwargs): return self._random.randint(*args, **kwargs) def random_seed_int(self) -> int: - return self.randint(low=0, high=2 ** 32 - 1, dtype="uint64") + return self.randint(low=0, high=2**32 - 1, dtype="uint64") def choice(self, *args, **kwargs): return self._random.choice(*args, **kwargs) @@ -132,7 +132,7 @@ def _fill_ints(self): # Generate more random values. Store as a list since generators # cannot be pickled. self._ints = self._random_generator.randint( - low=0, high=2 ** 32 - 1, size=self._batch_size, dtype="uint64" + low=0, high=2**32 - 1, size=self._batch_size, dtype="uint64" ) self._index = 0 diff --git a/axelrod/strategies/hmm.py b/axelrod/strategies/hmm.py index f91fd31ad..92038411e 100644 --- a/axelrod/strategies/hmm.py +++ b/axelrod/strategies/hmm.py @@ -327,7 +327,7 @@ def _normalize_parameters( emission_probabilities = list(map(float, emission_probabilities)) num_states = len(emission_probabilities) if mutation_probability is None: - mutation_probability = 10 / (num_states ** 2) + mutation_probability = 10 / (num_states**2) else: mutation_probability = mutation_probability return ( @@ -432,7 +432,7 @@ class with self.num_states. entry is the initial_action. """ - assert len(vector) == 2 * self.num_states ** 2 + self.num_states + 1 + assert len(vector) == 2 * self.num_states**2 + self.num_states + 1 def deserialize(vector): matrix = [] @@ -442,9 +442,9 @@ def deserialize(vector): matrix.append(row) return matrix - break_tc = self.num_states ** 2 - break_td = 2 * self.num_states ** 2 - break_ep = 2 * self.num_states ** 2 + self.num_states + break_tc = self.num_states**2 + break_td = 2 * self.num_states**2 + break_ep = 2 * self.num_states**2 + self.num_states initial_state = 0 self.hmm = SimpleHMM( deserialize(vector[0:break_tc]), @@ -457,7 +457,7 @@ def deserialize(vector): def create_vector_bounds(self): """Creates the bounds for the decision variables.""" - vec_len = 2 * self.num_states ** 2 + self.num_states + 1 + vec_len = 2 * self.num_states**2 + self.num_states + 1 lb = [0.0] * vec_len ub = [1.0] * vec_len return lb, ub diff --git a/axelrod/tests/strategies/test_hmm.py b/axelrod/tests/strategies/test_hmm.py index beffae2c5..4941ed53e 100644 --- a/axelrod/tests/strategies/test_hmm.py +++ b/axelrod/tests/strategies/test_hmm.py @@ -266,7 +266,7 @@ def test_vector_to_instance(self): def test_create_vector_bounds(self): num_states = 4 - size = 2 * num_states ** 2 + num_states + 1 + size = 2 * num_states**2 + num_states + 1 player = self.player_class(num_states=num_states, seed=1) lb, ub = player.create_vector_bounds() diff --git a/axelrod/tests/strategies/test_player.py b/axelrod/tests/strategies/test_player.py index 95f2d71f6..de23ffa9d 100644 --- a/axelrod/tests/strategies/test_player.py +++ b/axelrod/tests/strategies/test_player.py @@ -138,7 +138,7 @@ def test_clone(self): player2 = player1.clone() turns = 50 for op in [axl.Cooperator(), axl.Defector(), axl.TitForTat()]: - seed = random.randint(0, 10 ** 6) + seed = random.randint(0, 10**6) for p in [player1, player2]: m = axl.Match((p, op), turns=turns, reset=True, seed=seed) m.play() diff --git a/citations.md b/citations.md index 7d75d0c9f..99f6eb8e6 100644 --- a/citations.md +++ b/citations.md @@ -1,7 +1,6 @@ # Citations ### 2021 - * Glynatsi, Nikoleta E., and Vincent A. Knight. "A bibliometric study of research topics, collaboration, and centrality in the iterated prisoner’s dilemma." Humanities and Social Sciences Communications 8.1 (2021): 1-12. [Nature.com](https://www.nature.com/articles/s41599-021-00718-9) [ArXiv](https://arxiv.org/abs/1911.06128) * Glynatsi, Nikoleta E., and Vincent A. Knight. "Game Theory and Python: An educational tutorial to game theory and repeated games using Python." Journal of Open Source Education, 4(39), 78. [jose.theoj.org](https://doi.org/10.21105/jose.00078) @@ -47,6 +46,7 @@ ### Disserations +* Dollbo, Anna. MIXED MEMORY Q-LEARNER: An adaptive reinforcement learning algorithm for the Iterated Prisoner’s Dilemma. [BS thesis](https://gupea.ub.gu.se/handle/2077/69664). 2021. * Glynatsi, Nikoleta. "Understanding responses to environments for the Prisoner's Dilemma: A meta analysis, multidimensional optimisation and machine learning approach". PhD Thesis, Cardiff University. (2020) [Available Online](http://orca.cf.ac.uk/135221/). * Santana, Jonas Cardoso Carvalho. "Aprendizado de máquina e o dilema dos prisioneiros". (2020) * Black, Ben. "An Empirical Evaluation of the Ohtsuki-Nowak Approximation." [Master's Thesis](https://www.lancaster.ac.uk/~blackb/documents/MScDiss.pdf). (2018).