@@ -30,7 +30,7 @@ def close(self):
30
30
## Objective functions for optimization
31
31
32
32
def prepare_objective (name = "score" , turns = 200 , noise = 0. , repetitions = None ,
33
- nmoran = None ):
33
+ nmoran = None , match_attributes = None ):
34
34
name = name .lower ()
35
35
if name not in ["score" , "score_diff" , "moran" ]:
36
36
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,
40
40
if nmoran is None :
41
41
nmoran = 4
42
42
objective = partial (objective_moran_win , turns = turns , noise = noise ,
43
- repetitions = repetitions , N = nmoran )
43
+ repetitions = repetitions , N = nmoran ,
44
+ match_attributes = match_attributes )
44
45
elif name == "score" :
45
46
if repetitions is None :
46
47
repetitions = 20
47
48
objective = partial (objective_score , turns = turns , noise = noise ,
48
- repetitions = repetitions )
49
+ repetitions = repetitions ,
50
+ match_attributes = match_attributes )
49
51
elif name == "score_diff" :
50
52
if repetitions is None :
51
53
repetitions = 20
52
54
objective = partial (objective_score_diff , turns = turns , noise = noise ,
53
- repetitions = repetitions )
55
+ repetitions = repetitions ,
56
+ match_attributes = match_attributes )
54
57
return objective
55
58
56
59
57
- def objective_score (me , other , turns , noise , repetitions ):
60
+ def objective_score (me , other , turns , noise , repetitions , match_attributes = None ):
58
61
"""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 )
60
64
if not match ._stochastic :
61
65
repetitions = 1
62
66
scores_for_this_opponent = []
@@ -67,9 +71,11 @@ def objective_score(me, other, turns, noise, repetitions):
67
71
return scores_for_this_opponent
68
72
69
73
70
- def objective_score_diff (me , other , turns , noise , repetitions ):
74
+ def objective_score_diff (me , other , turns , noise , repetitions ,
75
+ match_attributes = None ):
71
76
"""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 )
73
79
if not match ._stochastic :
74
80
repetitions = 1
75
81
scores_for_this_opponent = []
@@ -82,7 +88,8 @@ def objective_score_diff(me, other, turns, noise, repetitions):
82
88
return scores_for_this_opponent
83
89
84
90
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 ):
86
93
"""Objective function to maximize Moran fixations over N=4 matches"""
87
94
population = []
88
95
for _ in range (N ):
0 commit comments