Joffrey Thomas
commited on
Commit
Β·
664783c
1
Parent(s):
cc1c341
update scoreboard
Browse files
app.py
CHANGED
|
@@ -358,7 +358,7 @@ def gr_submit_guess(round_id: str, lat: float, lng: float, username: str, reques
|
|
| 358 |
rnd['human_guess'] = {'lat': float(lat), 'lng': float(lng)}
|
| 359 |
rnd['human_score'] = score
|
| 360 |
rnd['human_distance_km'] = float(distance_km)
|
| 361 |
-
result_text = f"Your guess was {distance_km:.2f} km away
|
| 362 |
scoreboard_html = (
|
| 363 |
f"<div style='margin:8px 0;padding:26px;background:#040b1a;border-radius:18px;color:#f9fafb;border:1px solid rgba(148,163,184,0.4);box-shadow:0 26px 60px rgba(4,7,15,0.6);'>"
|
| 364 |
f"<div style='font-weight:700;font-size:1.25rem;margin-bottom:14px;text-shadow:0 0 12px rgba(4,7,15,0.75);'>Human Guess Recorded</div>"
|
|
@@ -437,6 +437,12 @@ def geocode_text_to_coords(query: str) -> Optional[Dict[str, float]]:
|
|
| 437 |
return None
|
| 438 |
|
| 439 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 440 |
load_zones_from_file()
|
| 441 |
|
| 442 |
def _read_text(path: str) -> str:
|
|
@@ -811,13 +817,15 @@ with gr.Blocks(css=APP_CSS, title="LLM GeoGuessr") as demo:
|
|
| 811 |
import html as _html
|
| 812 |
ai_text_safe = _html.escape(last_text or "")
|
| 813 |
summary_safe = _html.escape(txt)
|
|
|
|
|
|
|
| 814 |
scoreboard_html = (
|
| 815 |
f"<div style='margin:8px 0;padding:24px;background:#09101f;border-radius:18px;color:#f9fafb;border:1px solid rgba(148,163,184,0.35);box-shadow:0 22px 60px rgba(8,12,24,0.6);'>"
|
| 816 |
f"<div style='font-weight:700;font-size:1.25rem;margin-bottom:12px;text-shadow:0 0 12px rgba(8,12,24,0.8);'>Round {round_idx}</div>"
|
| 817 |
f"<div style='margin-bottom:18px;color:#f8fafc;font-size:1rem;line-height:1.55;text-shadow:0 0 10px rgba(8,12,24,0.75);'>{summary_safe}</div>"
|
| 818 |
f"<div style='display:flex;gap:26px;font-size:0.98rem;margin-bottom:18px;flex-wrap:wrap;'>"
|
| 819 |
-
f" <span><strong>Human:</strong> {rnd.get('human_score',0):.0f} pts ( {
|
| 820 |
-
f" <span><strong>AI:</strong> {rnd.get('ai_score',0):.0f} pts ( {
|
| 821 |
f"</div>"
|
| 822 |
f"<div style='margin-bottom:16px;font-weight:600;font-size:1rem;color:#e2e8f0;text-shadow:0 0 10px rgba(8,12,24,0.65);'>Totals β Human {total_human:.0f} / AI {total_ai:.0f}</div>"
|
| 823 |
f"<div id='ai-analysis-box' style='background:#f1f5f9; border-radius:14px;border:1px solid rgba(148,163,184,0.45);padding:16px;max-height:280px;overflow:auto;'>"
|
|
|
|
| 358 |
rnd['human_guess'] = {'lat': float(lat), 'lng': float(lng)}
|
| 359 |
rnd['human_score'] = score
|
| 360 |
rnd['human_distance_km'] = float(distance_km)
|
| 361 |
+
result_text = f"Your guess was {distance_km:.2f} km away. You scored {score:.0f} points."
|
| 362 |
scoreboard_html = (
|
| 363 |
f"<div style='margin:8px 0;padding:26px;background:#040b1a;border-radius:18px;color:#f9fafb;border:1px solid rgba(148,163,184,0.4);box-shadow:0 26px 60px rgba(4,7,15,0.6);'>"
|
| 364 |
f"<div style='font-weight:700;font-size:1.25rem;margin-bottom:14px;text-shadow:0 0 12px rgba(4,7,15,0.75);'>Human Guess Recorded</div>"
|
|
|
|
| 437 |
return None
|
| 438 |
|
| 439 |
|
| 440 |
+
def format_coords(coords: Optional[Dict[str, float]]) -> str:
|
| 441 |
+
if not coords or 'lat' not in coords or 'lng' not in coords:
|
| 442 |
+
return "N/A"
|
| 443 |
+
return f"lat: {coords['lat']:.2f}, lng: {coords['lng']:.2f}"
|
| 444 |
+
|
| 445 |
+
|
| 446 |
load_zones_from_file()
|
| 447 |
|
| 448 |
def _read_text(path: str) -> str:
|
|
|
|
| 817 |
import html as _html
|
| 818 |
ai_text_safe = _html.escape(last_text or "")
|
| 819 |
summary_safe = _html.escape(txt)
|
| 820 |
+
human_guess_str = format_coords(rnd.get('human_guess'))
|
| 821 |
+
ai_guess_str = format_coords(rnd.get('ai_guess'))
|
| 822 |
scoreboard_html = (
|
| 823 |
f"<div style='margin:8px 0;padding:24px;background:#09101f;border-radius:18px;color:#f9fafb;border:1px solid rgba(148,163,184,0.35);box-shadow:0 22px 60px rgba(8,12,24,0.6);'>"
|
| 824 |
f"<div style='font-weight:700;font-size:1.25rem;margin-bottom:12px;text-shadow:0 0 12px rgba(8,12,24,0.8);'>Round {round_idx}</div>"
|
| 825 |
f"<div style='margin-bottom:18px;color:#f8fafc;font-size:1rem;line-height:1.55;text-shadow:0 0 10px rgba(8,12,24,0.75);'>{summary_safe}</div>"
|
| 826 |
f"<div style='display:flex;gap:26px;font-size:0.98rem;margin-bottom:18px;flex-wrap:wrap;'>"
|
| 827 |
+
f" <span><strong>Human:</strong> {rnd.get('human_score',0):.0f} pts ( {human_guess_str} ) <span style='color:#dbeafe;'>({rnd.get('human_distance_km',0.0):.1f} km)</span></span>"
|
| 828 |
+
f" <span><strong>AI:</strong> {rnd.get('ai_score',0):.0f} pts ( {ai_guess_str} ) <span style='color:#dbeafe;'>({rnd.get('ai_distance_km',0.0):.1f} km)</span></span>"
|
| 829 |
f"</div>"
|
| 830 |
f"<div style='margin-bottom:16px;font-weight:600;font-size:1rem;color:#e2e8f0;text-shadow:0 0 10px rgba(8,12,24,0.65);'>Totals β Human {total_human:.0f} / AI {total_ai:.0f}</div>"
|
| 831 |
f"<div id='ai-analysis-box' style='background:#f1f5f9; border-radius:14px;border:1px solid rgba(148,163,184,0.45);padding:16px;max-height:280px;overflow:auto;'>"
|