Skip to content
Merged
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
10 changes: 5 additions & 5 deletions axelrod/ecosystem.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from axelrod.result_set import ResultSet
import random


from typing import List, Callable
class Ecosystem(object):
"""Create an ecosystem based on the payoff matrix from an Axelrod
tournament."""

def __init__(self, results, fitness=None, population=None):
def __init__(self, results: ResultSet, fitness: Callable[[float], float] =None, population: List[int] =None) -> None:

self.results = results
self.nplayers = self.results.nplayers
Expand Down Expand Up @@ -37,7 +37,7 @@ def __init__(self, results, fitness=None, population=None):
else:
self.fitness = lambda p: p

def reproduce(self, turns):
def reproduce(self, turns: int):

for iturn in range(turns):

Expand All @@ -50,7 +50,7 @@ def reproduce(self, turns):
# normal distribution based on the payoff matrix and its standard
# deviations obtained from the iterated PD tournament run
# previously.
payoffs = [0 for ip in plist]
payoffs = [0.0 for ip in plist]
for ip in plist:
for jp in plist:
avg = self.payoff_matrix[ip][jp]
Expand Down