tenhou-python-bot icon indicating copy to clipboard operation
tenhou-python-bot copied to clipboard

Crash [Live dora tiles can't be less than 0]

Open Nihisil opened this issue 3 years ago • 1 comments

Bots played on commit: https://github.com/MahjongRepository/tenhou-python-bot/commit/1e4d477bf470c8a9024b4ad553ab47125b914903

Seed to reproduce:

15996451505448234089
2020-11-24_03_16_38.log-Traceback (most recent call last):
2020-11-24_03_16_38.log-  File "bots_battle.py", line 47, in main
2020-11-24_03_16_38.log-    manager.play_game()
2020-11-24_03_16_38.log-  File "/app/game/bots_battle/game_manager.py", line 105, in play_game
2020-11-24_03_16_38.log-    results = self.play_round()
2020-11-24_03_16_38.log-  File "/app/game/bots_battle/game_manager.py", line 435, in play_round
2020-11-24_03_16_38.log-    meld, discard_option = other_client.player.try_to_call_meld(tile, is_kamicha_discard)
2020-11-24_03_16_38.log-  File "/app/game/player.py", line 240, in try_to_call_meld
2020-11-24_03_16_38.log-    return self.ai.try_to_call_meld(tile, is_kamicha_discard)
2020-11-24_03_16_38.log-  File "/app/game/ai/main.py", line 126, in try_to_call_meld
2020-11-24_03_16_38.log-    meld, discard_option = self.current_strategy.try_to_call_meld(tile_136, is_kamicha_discard, tiles_136)
2020-11-24_03_16_38.log-  File "/app/game/ai/strategies/main.py", line 184, in try_to_call_meld
2020-11-24_03_16_38.log-    chosen_meld_dict = self._find_best_meld_to_open(tile, possible_melds, new_tiles, closed_hand, tile)
2020-11-24_03_16_38.log-  File "/app/game/ai/strategies/main.py", line 405, in _find_best_meld_to_open
2020-11-24_03_16_38.log-    selected_tile = self.player.ai.hand_builder.choose_tile_to_discard(after_meld=True)
2020-11-24_03_16_38.log-  File "/app/game/ai/hand_builder.py", line 47, in choose_tile_to_discard
2020-11-24_03_16_38.log-    discard_options, threatening_players = self.player.ai.defence.mark_tiles_danger_for_threats(discard_options)
2020-11-24_03_16_38.log-  File "/app/game/ai/defence/main.py", line 482, in mark_tiles_danger_for_threats
2020-11-24_03_16_38.log-    discard_options = self.calculate_danger_borders(discard_options, threatening_player, threatening_players)
2020-11-24_03_16_38.log-  File "/app/game/ai/defence/main.py", line 206, in calculate_danger_borders
2020-11-24_03_16_38.log-    threatening_player_hand_cost = threatening_player.get_assumed_hand_cost(tile_136)
2020-11-24_03_16_38.log-  File "/app/game/ai/defence/enemy_analyzer.py", line 161, in get_assumed_hand_cost
2020-11-24_03_16_38.log-    return self._calculate_assumed_hand_cost_for_riichi(tile_136)
2020-11-24_03_16_38.log-  File "/app/game/ai/defence/enemy_analyzer.py", line 272, in _calculate_assumed_hand_cost_for_riichi
2020-11-24_03_16_38.log-    assert live_dora_tiles >= 0, "Live dora tiles can't be less than 0"
2020-11-24_03_16_38.log-AssertionError: Live dora tiles can't be less than 0

Nihisil avatar Dec 08 '20 07:12 Nihisil

Проблема в том, что shouminkan неправильно сериализируется в тенховский формат и из-за этого called tile добавляется в revealed_tiles дважды.

Возможно дело в этой строчке: https://github.com/MahjongRepository/tenhou-python-bot/blob/b630c1cb76eeade7956323ef849b0dae649df55e/project/game/bots_battle/replays/tenhou.py#L281

Нужно собрать больше примеров с самой тенхи.

Баг не критичный потому что он не в логике бота, а в сериализаторе локальных игр.

Nihisil avatar Oct 23 '21 03:10 Nihisil