@@ -137,8 +137,19 @@ def compute_normalised_state_distribution(interactions):
137137
138138def compute_state_to_action_distribution (interactions ):
139139 """
140- Returns the count of each state to action
141- for a set of interactions.
140+ Returns a list (for each player) of counts of each state to action pair
141+ for a set of interactions. A state to action pair is of the form:
142+
143+ ((C, D), C)
144+
145+ Implying that from a state of (C, D) (the first player having played C and
146+ the second playing D) the player in question then played C.
147+
148+ The following counter object, implies that the player in question was in
149+ state (C, D) for a total of 12 times, subsequently cooperating 4 times and
150+ defecting 8 times.
151+
152+ Counter({((C, D), C): 4, ((C, D), D): 8})
142153
143154 Parameters
144155 ----------
@@ -149,7 +160,9 @@ def compute_state_to_action_distribution(interactions):
149160 Returns
150161 ----------
151162 state_to_C_distributions : List of Counter Object
152- List of Dictionaries where the keys are the states and actions
163+ List of Counter objects where the keys are the states and actions and
164+ the values the counts. The
165+ first/second Counter corresponds to the first/second player.
153166 """
154167 if not interactions :
155168 return None
@@ -165,6 +178,21 @@ def compute_normalised_state_to_action_distribution(interactions):
165178 Returns the normalised count of each state to action
166179 for a set of interactions.
167180
181+ Returns a list (for each player) of normlised counts of each state to action
182+ pair for a set of interactions. A state to action pair is of the form:
183+
184+ ((C, D), C)
185+
186+ Implying that from a state of (C, D) (the first player having played C and
187+ the second playing D) the player in question then played C.
188+
189+ The following counter object, implies that the player in question was only
190+ ever in
191+ state (C, D), subsequently cooperating 1/3 of the time and
192+ defecting 2/3 times.
193+
194+ Counter({((C, D), C): 0.333333, ((C, D), D): 0.66666667})
195+
168196 Parameters
169197 ----------
170198 interactions : list of tuples
@@ -174,9 +202,9 @@ def compute_normalised_state_to_action_distribution(interactions):
174202 Returns
175203 ----------
176204 normalised_state_to_C_distributions : List of Counter Object
177- List of Dictionaries where the keys are the states and actions and the
178- values
179- the proportion of times that state resulted in a cooperation .
205+ List of Counter objects where the keys are the states and actions and
206+ the values the normalized counts.. The
207+ first/second Counter corresponds to the first/second player .
180208 """
181209 if not interactions :
182210 return None
@@ -198,8 +226,6 @@ def compute_normalised_state_to_action_distribution(interactions):
198226 return normalized_distribution
199227
200228
201-
202-
203229def sparkline (actions , c_symbol = '█' , d_symbol = ' ' ):
204230 return '' .join ([
205231 c_symbol if play == 'C' else d_symbol for play in actions ])
0 commit comments