def _init_acquire_currently_occupied_lot(self):
"""If there are no vacant lots in town, acquire a lot and demolish the home currently on it."""
lot_scores = self._rate_all_occupied_lots()
if len(lot_scores) >= 3:
# Pick from top three
top_three_choices = heapq.nlargest(3, lot_scores, key=lot_scores.get)
if random.random() < 0.6:
choice = top_three_choices[0]
elif random.random() < 0.9:
choice = top_three_choices[1]
else:
choice = top_three_choices[2]
elif lot_scores:
choice = max(lot_scores)
else:
raise Exception("A company attempted to secure an *occupied* lot in town but somehow could not.")
return choice
评论列表
文章目录