Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -371,36 +371,33 @@ def update(model_id_white, model_id_black):
|
|
371 |
if result == "1-0":
|
372 |
new_elo_white = calculate_elo(current_elo_white, current_elo_black, 1)
|
373 |
new_elo_black = calculate_elo(current_elo_black, current_elo_white, 0)
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
)
|
382 |
elif result == "0-1":
|
383 |
new_elo_white = calculate_elo(current_elo_white, current_elo_black, 0)
|
384 |
new_elo_black = calculate_elo(current_elo_black, current_elo_white, 1)
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
)
|
393 |
elif result == "1/2-1/2":
|
394 |
new_elo_white = calculate_elo(current_elo_white, current_elo_black, 0.5)
|
395 |
new_elo_black = calculate_elo(current_elo_black, current_elo_white, 0.5)
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
)
|
404 |
elif result == "*":
|
405 |
print(f"Ongoing game! ({termination})")
|
406 |
|
@@ -457,7 +454,7 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
457 |
btn = gr.Button("Fight!")
|
458 |
with gr.Row():
|
459 |
gr.HTML("""<div id='chessboard' style='width: 50%; display: block;'></div>""")
|
460 |
-
out = gr.Image(value=image, show_label=False, show_share_button=False,
|
461 |
gr.HTML("""<div id='rightblock' style='width: 50%; display: block;'></div>""")
|
462 |
btn.click(fn=update, inputs=[model_id_white, model_id_black], outputs=out)
|
463 |
gr.Markdown('<div align="center"><p style="font-size: 30px;">🏆 Leaderboard</p></div>')
|
|
|
371 |
if result == "1-0":
|
372 |
new_elo_white = calculate_elo(current_elo_white, current_elo_black, 1)
|
373 |
new_elo_black = calculate_elo(current_elo_black, current_elo_white, 0)
|
374 |
+
update_str = f"""{model_id_white} wins! ({termination})
|
375 |
+
ELO change:
|
376 |
+
* {model_id_white}: {current_elo_white} -> {new_elo_white} ({new_elo_white - current_elo_white:+})
|
377 |
+
* {model_id_black}: {current_elo_black} -> {new_elo_black} ({new_elo_black - current_elo_black:+})
|
378 |
+
"""
|
379 |
+
gr.Info(update_str)
|
380 |
+
print(update_str)
|
|
|
381 |
elif result == "0-1":
|
382 |
new_elo_white = calculate_elo(current_elo_white, current_elo_black, 0)
|
383 |
new_elo_black = calculate_elo(current_elo_black, current_elo_white, 1)
|
384 |
+
update_str = f"""{model_id_black} wins! ({termination})
|
385 |
+
ELO change:
|
386 |
+
* {model_id_white}: {current_elo_white} -> {new_elo_white} ({new_elo_white - current_elo_white:+})
|
387 |
+
* {model_id_black}: {current_elo_black} -> {new_elo_black} ({new_elo_black - current_elo_black:+})
|
388 |
+
"""
|
389 |
+
gr.Info(update_str)
|
390 |
+
print(update_str)
|
|
|
391 |
elif result == "1/2-1/2":
|
392 |
new_elo_white = calculate_elo(current_elo_white, current_elo_black, 0.5)
|
393 |
new_elo_black = calculate_elo(current_elo_black, current_elo_white, 0.5)
|
394 |
+
update_str = f"""Draw! ({termination})
|
395 |
+
ELO change:
|
396 |
+
* {model_id_white}: {current_elo_white} -> {new_elo_white} ({new_elo_white - current_elo_white:+})
|
397 |
+
* {model_id_black}: {current_elo_black} -> {new_elo_black} ({new_elo_black - current_elo_black:+})
|
398 |
+
"""
|
399 |
+
gr.Info(update_str)
|
400 |
+
print(update_str)
|
|
|
401 |
elif result == "*":
|
402 |
print(f"Ongoing game! ({termination})")
|
403 |
|
|
|
454 |
btn = gr.Button("Fight!")
|
455 |
with gr.Row():
|
456 |
gr.HTML("""<div id='chessboard' style='width: 50%; display: block;'></div>""")
|
457 |
+
out = gr.Image(value=image, show_label=False, show_share_button=False, elem_id="chessboard")
|
458 |
gr.HTML("""<div id='rightblock' style='width: 50%; display: block;'></div>""")
|
459 |
btn.click(fn=update, inputs=[model_id_white, model_id_black], outputs=out)
|
460 |
gr.Markdown('<div align="center"><p style="font-size: 30px;">🏆 Leaderboard</p></div>')
|