add file to analyze bdrs

This commit is contained in:
Maximilian Keßler 2023-11-10 10:59:35 +01:00
parent c931c9e3db
commit 7f1df756b2
Signed by: max
GPG key ID: BCC5A619923C0BA5

28
bdr.py Normal file
View file

@ -0,0 +1,28 @@
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