def test(self, table_sl): builder = PokerTreeBuilder() params = {} params['root_node'] = {} params['root_node']['board'] = card_to_string.string_to_board('') params['root_node']['street'] = 0 params['root_node']['current_player'] = constants.players.P1 params['root_node']['bets'] = arguments.Tensor([100, 100]) params['limit_to_street'] = False tree = builder.build_tree(params) # table_sl = torch.load('/home/mjb/Nutstore/deepStack/Data/Model/Iter:' + str(model_num) + '.sl') #constract the starting range filling = StrategyFilling() range1 = card_tools.get_uniform_range(params['root_node']['board']) range2 = card_tools.get_uniform_range(params['root_node']['board']) filling.fill_uniform(tree) starting_ranges = arguments.Tensor(game_settings.player_count, game_settings.card_count) starting_ranges[0].copy_(range1) starting_ranges[1].copy_(range2) table_sl.model.eval() # self.dfs_fill_table(tree, table_sl,builder) self.dfs_fill_strategy(table_sl,tree, builder) tree_values = TreeValues() tree_values.compute_values(tree, starting_ranges) print('Exploitability: ' + str(tree.exploitability.item()) + '[chips]' ) return tree.exploitability.item()
def resolve_first_node(self): ''' Solves a depth-limited lookahead from the first node of the game to get opponent counterfactual values. The cfvs are stored in the field `starting_cfvs_p1`. Because this is the first node of the game, exact ranges are known for both players, so opponent cfvs are not necessary for solving. ''' self.first_node_resolving = Resolving() first_node = Node() first_node.board = np.zeros([]) first_node.street = 1 first_node.current_player = constants.players.P1 first_node.bets = np.array([arguments.ante, arguments.ante], dtype=arguments.dtype) # create the starting ranges player_range = card_tools.get_uniform_range(first_node.board) opponent_range = card_tools.get_uniform_range(first_node.board) # create re-solving and re-solve the first node self.first_node_resolving = Resolving() self.first_node_resolving.resolve_first_node(first_node, player_range, opponent_range) # store the initial CFVs self.starting_cfvs_p1 = self.first_node_resolving.get_root_cfv()
def __init__(self): ''' Does a depth-limited solve of the game's first node. ''' self.starting_player_range = card_tools.get_uniform_range(np.zeros([]))
builder = PokerTreeBuilder() params = {} params['root_node'] = {} params['root_node']['board'] = card_to_string.string_to_board('Ks') params['root_node']['street'] = 1 params['root_node']['current_player'] = constants.players.P1 params['root_node']['bets'] = arguments.Tensor([100, 100]) params['limit_to_street'] = True tree = builder.build_tree(params) filling = StrategyFilling() range1 = card_tools.get_uniform_range(params['root_node']['board']) range2 = card_tools.get_uniform_range(params['root_node']['board']) filling.fill_uniform(tree) starting_ranges = arguments.Tensor(constants.players_count, game_settings.card_count) starting_ranges[0].copy_(range1) starting_ranges[1].copy_(range2) #tree_values = TreeValues() #tree_values:compute_values(tree, starting_ranges) #print('Exploitability: ' + tree.exploitability + '[chips]' ) visualiser = TreeVisualiser()
from time import time PC, CC = constants.players_count, game_settings.card_count params = TreeParams() params.root_node = Node() params.root_node.board = card_to_string.string_to_board('') params.root_node.street = 1 params.root_node.current_player = constants.players.P1 params.root_node.bets = np.array([100, 100]) tree = tree_builder.build_tree(params) starting_ranges = np.zeros([PC, CC], dtype=arguments.dtype) starting_ranges[0] = card_tools.get_uniform_range(params.root_node.board) starting_ranges[1] = card_tools.get_uniform_range(params.root_node.board) t0 = time() tree_cfr = TreeCFR() tree_cfr.run_cfr(tree, starting_ranges) print(time() - t0) tree_values = TreeValues() tree_values.compute_values(tree, starting_ranges) print('Exploitability: ' + str(tree.exploitability) + ' [chips]') print(np.array2string(tree.strategy, suppress_small=True, precision=2)) # tree_visualizer.draw_tree(tree)