File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
mesa/examples/advanced/sugarscape_g1mt Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -239,15 +239,13 @@ def move(self):
239239
240240 # find the highest welfare in welfares
241241 max_welfare = max (welfares )
242- # get the index of max welfare cells
243- # fixme: rewrite using enumerate and single loop
244- candidate_indices = [
245- i for i in range (len (welfares )) if math .isclose (welfares [i ], max_welfare )
242+ # Get cells with the highest welfare
243+ candidates = [
244+ cell
245+ for cell , welfare in zip (neighboring_cells , welfares )
246+ if math .isclose (welfare , max_welfare )
246247 ]
247248
248- # convert index to positions of those cells
249- candidates = [neighboring_cells [i ] for i in candidate_indices ]
250-
251249 min_dist = min (get_distance (self .cell , cell ) for cell in candidates )
252250
253251 final_candidates = [
You can’t perform that action at this time.
0 commit comments