29 lines
971 B
Python
29 lines
971 B
Python
|
from typing import List, Dict
|
||
|
|
||
|
from hanabi.hanab_game import Action, ActionType
|
||
|
from hanabi.live.hanab_live import HanabLiveInstance, parse_json_game, HanabLiveGameState
|
||
|
|
||
|
|
||
|
def get_bdrs(instance: HanabLiveInstance, actions: List[Action]) -> List[int]:
|
||
|
bdrs = []
|
||
|
game = HanabLiveGameState(instance)
|
||
|
for action in actions:
|
||
|
if action.type == ActionType.Discard:
|
||
|
discard = instance.deck[action.target]
|
||
|
if not game.is_trash(discard):
|
||
|
if discard.rank != 1:
|
||
|
if discard in game.deck[game.progress:]:
|
||
|
bdrs.append(game.draw_pile_size)
|
||
|
else:
|
||
|
if game.deck[game.progress:].count(discard) == 2:
|
||
|
bdrs.append(game.draw_pile_size)
|
||
|
game.make_action(action)
|
||
|
return bdrs
|
||
|
|
||
|
|
||
|
def describe_game(game_json: Dict):
|
||
|
instance, actions = parse_json_game(game_json)
|
||
|
bdrs = get_bdrs(instance, actions)
|
||
|
return bdrs
|
||
|
|