Skip to content

Commit 76e098e

Browse files
Merge pull request #796 from Axelrod-Python/moran
Moran processes are always stochastic
2 parents 59752b8 + 10692f7 commit 76e098e

File tree

2 files changed

+3
-27
lines changed

2 files changed

+3
-27
lines changed

axelrod/moran.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# -*- coding: utf-8 -*-
21
from collections import Counter
32
import random
43

54
import numpy as np
65

76
from .deterministic_cache import DeterministicCache
8-
from .match import Match, is_stochastic
7+
from .match import Match
98
from .random_ import randrange
109

1110

@@ -94,14 +93,6 @@ def set_players(self):
9493
self.populations = [self.population_distribution()]
9594
self.num_players = len(self.players)
9695

97-
@property
98-
def _stochastic(self):
99-
"""
100-
A boolean to show whether a match between two players would be
101-
stochastic
102-
"""
103-
return is_stochastic(self.players, self.noise) or (self.mutation_rate > 0)
104-
10596
def mutate(self, index):
10697
# If mutate, choose another strategy at random from the initial population
10798
r = random.random()

axelrod/tests/unit/test_moran.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
# -*- coding: utf-8 -*-
21
from collections import Counter
32
import itertools
43
import random
54
import unittest
65

6+
from hypothesis import given, example, settings
7+
78
import axelrod
89
from axelrod import MoranProcess
910
from axelrod.moran import fitness_proportionate_selection
10-
11-
from hypothesis import given, example, settings
12-
1311
from axelrod.tests.property import strategy_lists
1412

1513

@@ -21,17 +19,6 @@ def test_fps(self):
2119
self.assertEqual(fitness_proportionate_selection([1, 1, 1]), 0)
2220
self.assertEqual(fitness_proportionate_selection([1, 1, 1]), 2)
2321

24-
def test_stochastic(self):
25-
p1, p2 = axelrod.Cooperator(), axelrod.Cooperator()
26-
mp = MoranProcess((p1, p2))
27-
self.assertFalse(mp._stochastic)
28-
p1, p2 = axelrod.Cooperator(), axelrod.Cooperator()
29-
mp = MoranProcess((p1, p2), noise=0.05)
30-
self.assertTrue(mp._stochastic)
31-
p1, p2 = axelrod.Cooperator(), axelrod.Random()
32-
mp = MoranProcess((p1, p2))
33-
self.assertTrue(mp._stochastic)
34-
3522
def test_exit_condition(self):
3623
p1, p2 = axelrod.Cooperator(), axelrod.Cooperator()
3724
mp = MoranProcess((p1, p2))
@@ -62,7 +49,6 @@ def test_two_players_with_mutation(self):
6249
p1, p2 = axelrod.Cooperator(), axelrod.Defector()
6350
random.seed(5)
6451
mp = MoranProcess((p1, p2), mutation_rate=0.2)
65-
self.assertEqual(mp._stochastic, True)
6652
self.assertDictEqual(mp.mutation_targets, {str(p1): [p2], str(p2): [p1]})
6753
# Test that mutation causes the population to alternate between fixations
6854
counters = [
@@ -99,7 +85,6 @@ def test_three_players_with_mutation(self):
9985
p3 = axelrod.Defector()
10086
players = [p1, p2, p3]
10187
mp = MoranProcess(players, mutation_rate=0.2)
102-
self.assertEqual(mp._stochastic, True)
10388
self.assertDictEqual(mp.mutation_targets, {str(p1): [p3, p2], str(p2): [p1, p3], str(p3): [p1, p2]})
10489
# Test that mutation causes the population to alternate between fixations
10590
counters = [

0 commit comments

Comments
 (0)