forked from Hanabi/hanabi-league
generate game pages also for games with no endgame analysis
This commit is contained in:
parent
145142c4a9
commit
cf9a81979a
2 changed files with 33 additions and 24 deletions
|
@ -784,14 +784,14 @@ def convert_endgame_action(endgame_action: endgames.EndgameAction, game: hanabi.
|
||||||
def get_endgame_page_data():
|
def get_endgame_page_data():
|
||||||
cur = conn_manager.get_new_cursor()
|
cur = conn_manager.get_new_cursor()
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"SELECT game_id "
|
"SELECT games.id, termination_reason "
|
||||||
"FROM games "
|
"FROM games "
|
||||||
"LEFT OUTER JOIN endgames_analyzed "
|
"LEFT OUTER JOIN endgames_analyzed "
|
||||||
" ON endgames_analyzed.game_id = games.id "
|
" ON endgames_analyzed.game_id = games.id "
|
||||||
"WHERE termination_reason IS NOT NULL"
|
|
||||||
)
|
)
|
||||||
ret = {}
|
ret = {}
|
||||||
for (game_id, ) in cur.fetchall():
|
for (game_id, termination_reason) in cur.fetchall():
|
||||||
|
if termination_reason is not None:
|
||||||
ret[game_id] = []
|
ret[game_id] = []
|
||||||
instance, actions, _ = games_db_interface.load_game_parts(game_id)
|
instance, actions, _ = games_db_interface.load_game_parts(game_id)
|
||||||
game = hanabi.hanab_game.GameState(instance)
|
game = hanabi.hanab_game.GameState(instance)
|
||||||
|
@ -815,6 +815,8 @@ def get_endgame_page_data():
|
||||||
ret[game_id].append(
|
ret[game_id].append(
|
||||||
(cur_turn, best_action, other_actions)
|
(cur_turn, best_action, other_actions)
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
ret[game_id] = None
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
<h4>
|
<h4>
|
||||||
Endgame Analysis table
|
Endgame Analysis table
|
||||||
</h4>
|
</h4>
|
||||||
|
{% if data %}
|
||||||
<table class="endgame-table">
|
<table class="endgame-table">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Turn</th>
|
<th>Turn</th>
|
||||||
|
@ -59,6 +60,12 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
{% else %}
|
||||||
|
Currently, there is no endgame analysis available for this game. Since the computation is resource extensive,
|
||||||
|
this might take a while, also depending on how many other games have been played recently.
|
||||||
|
<br>
|
||||||
|
Come back later to check again.
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue