add file to analyze bdrs
This commit is contained in:
parent
c931c9e3db
commit
7f1df756b2
1 changed files with 28 additions and 0 deletions
28
bdr.py
Normal file
28
bdr.py
Normal 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
|
||||
|
Loading…
Reference in a new issue