Browse Source

Update 'server/lib.py'

kirkleon 5 years ago
parent
commit
6b0242c85d
1 changed files with 5 additions and 2 deletions
  1. 5 2
      server/lib.py

+ 5 - 2
server/lib.py

@@ -37,6 +37,8 @@ antipode_dist_km = math.pi * mean_earth_radius_km
 min_dist_km = 0.15  # if you're within 150m, you get a perfect score
 # if you're more than 1/4 of the Earth away, you get 0
 max_dist_km = antipode_dist_km / 2
+# this has been tuned by hand based on the max dist to get a nice Gaussian
+exp_denom = max_dist_km * max_dist_km / 4
 perfect_score = 5000
 
 
@@ -55,5 +57,6 @@ def score(target, guess):
     if dist_km >= max_dist_km:
         return 0, dist_km
 
-    # TODO probably still needs tweaking
-    return int(perfect_score * (1 - ((dist_km - min_dist_km) / max_dist_km) ** 0.5)), dist_km
+    # Gaussian, with some manual tuning to get good fall off
+    exponent = -((dist_km - min_dist_km) ^ 2) / exp_denom
+    return int(perfect_score * math.exp(exponent)), dist_km