Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reconcile Moran processes #1043

Merged
merged 7 commits into from
Jun 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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