Skip to content

Commit

Permalink
Merge pull request #1043 from Axelrod-Python/reconcile-moran-b
Browse files Browse the repository at this point in the history
Reconcile Moran processes
  • Loading branch information
meatballs authored Jun 13, 2017
2 parents 09a2206 + ce39975 commit 49fc54b
Show file tree
Hide file tree
Showing 7 changed files with 448 additions and 285 deletions.
2 changes: 1 addition & 1 deletion axelrod/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
update_history, update_state_distribution, Player)
from .mock_player import MockPlayer
from .match import Match
from .moran import MoranProcess, MoranProcessGraph, ApproximateMoranProcess
from .moran import MoranProcess, ApproximateMoranProcess
from .strategies import *
from .deterministic_cache import DeterministicCache
from .match_generator import *
Expand Down
15 changes: 11 additions & 4 deletions axelrod/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def add_edges(self, edges):
for edge in edges:
self.add_edge(*edge)

def add_loops(self):
"""
Add all loops to edges
"""
self.add_edges((i, i) for i, _ in enumerate(self.vertices()))

def edges(self):
return self._edges

Expand Down Expand Up @@ -116,13 +122,14 @@ def complete_graph(length, loops=True):
-------
a Graph object
"""
offset = 1
if loops:
offset = 0
graph = Graph(directed=False)
edges = []
for i in range(length):
for j in range(i + offset, length):
for j in range(i + 1, length):
edges.append((i, j))
graph.add_edges(edges)

if loops:
graph.add_loops()

return graph
Loading

0 comments on commit 49fc54b

Please sign in to comment.