From 4839bf49a64d76d1307f3adfc88cdb1581d7b36f Mon Sep 17 00:00:00 2001 From: spinerak Date: Mon, 10 Jun 2024 18:52:18 +0200 Subject: [PATCH] small optimization ListState --- worlds/yachtdice/Rules.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/worlds/yachtdice/Rules.py b/worlds/yachtdice/Rules.py index 8d288ce286..3fd63b2547 100644 --- a/worlds/yachtdice/Rules.py +++ b/worlds/yachtdice/Rules.py @@ -1,5 +1,5 @@ import math -from collections import defaultdict +from collections import Counter, defaultdict from typing import List, Optional from BaseClasses import MultiWorld @@ -69,12 +69,15 @@ class Category: return mean_score * self.quantity + + class ListState: def __init__(self, state: List[str]): self.state = state + self.item_counts = Counter(state) def count(self, item: str, player: Optional[str] = None) -> int: - return self.state.count(item) + return self.item_counts[item] def extract_progression(state, player, options):