|
@@ -34,6 +34,85 @@ class ExhaustedSourceError(Exception):
|
|
|
pass
|
|
|
|
|
|
|
|
|
+DIFFICULTY_1 = [
|
|
|
+ # Singapore - very small, pretty obvious from lang combo
|
|
|
+ "sg",
|
|
|
+ # Israel, Taiwan, Japan, South Korea, Greece, Poland - immediately obvious from language
|
|
|
+ "il", "tw", "jp", "kr", "gr", "pl",
|
|
|
+ # Hong Kong - distraction from Taiwan
|
|
|
+ "hk",
|
|
|
+]
|
|
|
+DIFFICULTY_2 = [
|
|
|
+ # USA! USA! USA! USA! (suck it Europe)
|
|
|
+ "us", "us", "us", "us",
|
|
|
+ # Western Europe minus a few more interesting ones
|
|
|
+ "ie", "gb", "es", "fr",
|
|
|
+ "be", "nl", "lu",
|
|
|
+ "de", "ch", "li", "at",
|
|
|
+ "it", "mt",
|
|
|
+ # Southern Africa (b/c English)
|
|
|
+ "za", "ls", "sz", "na", "bw", "zw",
|
|
|
+ # New Zealand (b/c English)
|
|
|
+ "nz",
|
|
|
+]
|
|
|
+DIFFICULTY_3 = [
|
|
|
+ # Nordic languages
|
|
|
+ "is", "fo", "se", "no", "dk", "gl",
|
|
|
+ # Finno-urgic
|
|
|
+ "fi", "ee",
|
|
|
+ # Other Baltics
|
|
|
+ "lv", "lt",
|
|
|
+ # Central + Eastern Europe + Balkans (non-Cyrillic, non-Polish confusable)
|
|
|
+ "cz", "sk", "hu", "ro", "si", "hr", "ba", "al", "md",
|
|
|
+ # Cyrillic Balkans
|
|
|
+ "bg", "rs", "me", "mk",
|
|
|
+ # Turkey can also have its language confused with some of the above
|
|
|
+ "tr",
|
|
|
+ # Caucasus
|
|
|
+ "am", "az", "ge",
|
|
|
+ # SE Asia (partial - mainly the ones with non-Latin scripts)
|
|
|
+ "bt", "np", "bd",
|
|
|
+ "mm", "kh", "vn", "th", "la",
|
|
|
+]
|
|
|
+DIFFICULTY_4 = [
|
|
|
+ # SE Asia (partial - mainly the ones with harder to differentiate languages)
|
|
|
+ "id", "my",
|
|
|
+ # Middle East
|
|
|
+ "iq", "jo", "lb", "sa", "ae", "om",
|
|
|
+ # North Africa
|
|
|
+ "eg", "dz", "tn", "ma",
|
|
|
+ # West Africa
|
|
|
+ "sn", "gi", "ng",
|
|
|
+ # East Africa
|
|
|
+ "ke", "et",
|
|
|
+ # Mexico + Central America + South America minus Brazil (i.e., all Spanish)
|
|
|
+ "mx", "gt", "ni", "pa", "co", "ec", "pe", "bo", "ar", "cl",
|
|
|
+]
|
|
|
+DIFFICULTY_5 = [
|
|
|
+ # Canada + Australia
|
|
|
+ "ca", "au",
|
|
|
+ # Brazil + Portugal (lol)
|
|
|
+ "br", "pt",
|
|
|
+ # Russia + other Cyrillic + Mongolia
|
|
|
+ "ru",
|
|
|
+ "ua", "by",
|
|
|
+ "kz", "kg", "tj", "tm", "uz",
|
|
|
+ "mn",
|
|
|
+ # India (basically all photo orbs)
|
|
|
+ "in",
|
|
|
+]
|
|
|
+DIFFICULTY_X = [
|
|
|
+ # tropical/subtropical island nations
|
|
|
+ "lk", "cv", "cu", "do", "jm", "mg", "mv", "pg", "ph", "ws", "tt", "pr",
|
|
|
+]
|
|
|
+DIFFICULTY_TIER_ORDER = (
|
|
|
+ DIFFICULTY_1, DIFFICULTY_2, DIFFICULTY_3, DIFFICULTY_4,
|
|
|
+ DIFFICULTY_5,
|
|
|
+ DIFFICULTY_4, DIFFICULTY_3, DIFFICULTY_2, DIFFICULTY_1,
|
|
|
+ DIFFICULTY_X,
|
|
|
+)
|
|
|
+
|
|
|
+
|
|
|
class PointStore:
|
|
|
def __init__(self,
|
|
|
cache_targets: Dict[Tuple[GenMethodEnum, CountryCode], int],
|
|
@@ -125,7 +204,29 @@ class PointStore:
|
|
|
most likely due to time constraints, this will raise an ExhaustedSourceError.
|
|
|
"""
|
|
|
try:
|
|
|
- point_tasks = [self.get_point(config.generation_method, config.country_lock) for _ in range(config.rounds)]
|
|
|
+ if config.generation_method == GenMethodEnum.diff_tiered:
|
|
|
+ # in the case of using the "difficulty tiered" generator there is some special logic
|
|
|
+ # assume that, in general, we want 10 points (4 normal rounds going up in difficulty, 1 max difficulty round, 4 normal going down, 1 nightmare tier)
|
|
|
+ # if more are requested, it repeats. if less, it only goes that far.
|
|
|
+
|
|
|
+ def make_point_task(tier, attempts):
|
|
|
+ if attempts <= 0:
|
|
|
+ raise ExhaustedSourceError
|
|
|
+
|
|
|
+ try:
|
|
|
+ country_lock = random.choice(tier)
|
|
|
+ if country_lock in random_street_view.VALID_COUNTRIES:
|
|
|
+ return self.get_point(GenMethodEnum.rsv, country_lock)
|
|
|
+ elif country_lock in urban_centers.VALID_COUNTRIES:
|
|
|
+ return self.get_point(GenMethodEnum.urban, country_lock)
|
|
|
+ else:
|
|
|
+ raise ExhaustedSourceError
|
|
|
+ except:
|
|
|
+ return make_point_task(tier, attempts - 1)
|
|
|
+
|
|
|
+ point_tasks = [make_point_task(DIFFICULTY_TIER_ORDER[i % len(DIFFICULTY_TIER_ORDER)], 3) for i in range(config.rounds)]
|
|
|
+ else:
|
|
|
+ point_tasks = [self.get_point(config.generation_method, config.country_lock) for _ in range(config.rounds)]
|
|
|
gathered = asyncio.gather(*point_tasks)
|
|
|
return await asyncio.wait_for(gathered, 60)
|
|
|
# TODO - it would be nice to keep partially generated sets around if there's a timeout or exhaustion
|