Browse Source

Implement first pass at country difficulty tiers

Kirk Trombley 3 years ago
parent
commit
215c17b2fb
1 changed files with 85 additions and 14 deletions
  1. 85 14
      server/app/point_gen/__init__.py

+ 85 - 14
server/app/point_gen/__init__.py

@@ -34,12 +34,77 @@ class ExhaustedSourceError(Exception):
     pass
 
 
-DIFFICULTY_1 = ["ee"] # TODO actually fill these out
-DIFFICULTY_2 = ["ee"]
-DIFFICULTY_3 = ["ee"]
-DIFFICULTY_4 = ["ee"]
-DIFFICULTY_5 = ["ee"]
-DIFFICULTY_X = ["ee"] # TODO all islands
+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,
@@ -144,16 +209,22 @@ class PointStore:
                 # 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):
-                    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:
+                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)]) for i in range(config.rounds)]
+                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)