@@ -30,7 +30,7 @@ def close(self):
3030## Objective functions for optimization
3131
3232def prepare_objective (name = "score" , turns = 200 , noise = 0. , repetitions = None ,
33- nmoran = None ):
33+ nmoran = None , match_attributes = None ):
3434 name = name .lower ()
3535 if name not in ["score" , "score_diff" , "moran" ]:
3636 raise ValueError ("Score must be one of score, score_diff, or moran" )
@@ -40,23 +40,27 @@ def prepare_objective(name="score", turns=200, noise=0., repetitions=None,
4040 if nmoran is None :
4141 nmoran = 4
4242 objective = partial (objective_moran_win , turns = turns , noise = noise ,
43- repetitions = repetitions , N = nmoran )
43+ repetitions = repetitions , N = nmoran ,
44+ match_attributes = match_attributes )
4445 elif name == "score" :
4546 if repetitions is None :
4647 repetitions = 20
4748 objective = partial (objective_score , turns = turns , noise = noise ,
48- repetitions = repetitions )
49+ repetitions = repetitions ,
50+ match_attributes = match_attributes )
4951 elif name == "score_diff" :
5052 if repetitions is None :
5153 repetitions = 20
5254 objective = partial (objective_score_diff , turns = turns , noise = noise ,
53- repetitions = repetitions )
55+ repetitions = repetitions ,
56+ match_attributes = match_attributes )
5457 return objective
5558
5659
57- def objective_score (me , other , turns , noise , repetitions ):
60+ def objective_score (me , other , turns , noise , repetitions , match_attributes = None ):
5861 """Objective function to maximize total score over matches."""
59- match = axl .Match ((me , other ), turns = turns , noise = noise )
62+ match = axl .Match ((me , other ), turns = turns , noise = noise ,
63+ match_attributes = match_attributes )
6064 if not match ._stochastic :
6165 repetitions = 1
6266 scores_for_this_opponent = []
@@ -67,9 +71,11 @@ def objective_score(me, other, turns, noise, repetitions):
6771 return scores_for_this_opponent
6872
6973
70- def objective_score_diff (me , other , turns , noise , repetitions ):
74+ def objective_score_diff (me , other , turns , noise , repetitions ,
75+ match_attributes = None ):
7176 """Objective function to maximize total score difference over matches."""
72- match = axl .Match ((me , other ), turns = turns , noise = noise )
77+ match = axl .Match ((me , other ), turns = turns , noise = noise ,
78+ match_attributes = match_attributes )
7379 if not match ._stochastic :
7480 repetitions = 1
7581 scores_for_this_opponent = []
@@ -82,7 +88,8 @@ def objective_score_diff(me, other, turns, noise, repetitions):
8288 return scores_for_this_opponent
8389
8490
85- def objective_moran_win (me , other , turns , noise , repetitions , N = 5 ):
91+ def objective_moran_win (me , other , turns , noise , repetitions , N = 5 ,
92+ match_attributes = None ):
8693 """Objective function to maximize Moran fixations over N=4 matches"""
8794 population = []
8895 for _ in range (N ):
0 commit comments