添加叫牌相关的评估逻辑

This commit is contained in:
zhiyang7 2021-12-10 10:11:44 +08:00
parent 0df61c62e3
commit 3300fd9658
3 changed files with 33 additions and 16 deletions

29
douzero/env/game.py vendored
View File

@ -86,15 +86,26 @@ class GameEnv(object):
def card_play_init(self, card_play_data): def card_play_init(self, card_play_data):
self.info_sets['landlord'].player_hand_cards = \ if 'bid' in card_play_data.keys():
card_play_data['landlord'] self.info_sets['landlord'].bid_info = card_play_data['bid']['landlord']
self.info_sets['landlord_up'].player_hand_cards = \ self.info_sets['landlord_up'].bid_info = card_play_data['bid']['landlord_up']
card_play_data['landlord_up'] self.info_sets['landlord_front'].bid_info = card_play_data['bid']['landlord_front']
self.info_sets['landlord_front'].player_hand_cards = \ self.info_sets['landlord_down'].bid_info = card_play_data['bid']['landlord_down']
card_play_data['landlord_front']
self.info_sets['landlord_down'].player_hand_cards = \ self.info_sets['landlord'].player_hand_cards = card_play_data['play']['landlord']
card_play_data['landlord_down'] self.info_sets['landlord_up'].player_hand_cards = card_play_data['play']['landlord_up']
# self.three_landlord_cards = card_play_data['three_landlord_cards'] self.info_sets['landlord_front'].player_hand_cards = card_play_data['play']['landlord_front']
self.info_sets['landlord_down'].player_hand_cards = card_play_data['play']['landlord_down']
else:
self.info_sets['landlord'].player_hand_cards = \
card_play_data['landlord']
self.info_sets['landlord_up'].player_hand_cards = \
card_play_data['landlord_up']
self.info_sets['landlord_front'].player_hand_cards = \
card_play_data['landlord_front']
self.info_sets['landlord_down'].player_hand_cards = \
card_play_data['landlord_down']
# self.three_landlord_cards = card_play_data['three_landlord_cards']
self.get_acting_player_position() self.get_acting_player_position()
self.game_infoset = self.get_infoset() self.game_infoset = self.get_infoset()

View File

@ -85,10 +85,16 @@ def mp_simulate(card_play_data_list, card_play_model_path_dict, q, output, bid_o
print(" bid: %i|%i%i|%i%i|%i (%.3f %.3f %.3f %.3f %.3f %.3f) %.1f" % (bid_results[0],bid_results[1],bid_results[2],bid_results[3],bid_results[4],bid_results[5],bid_values[0],bid_values[1],bid_values[2],bid_values[3],bid_values[4],bid_values[5], result2)) print(" bid: %i|%i%i|%i%i|%i (%.3f %.3f %.3f %.3f %.3f %.3f) %.1f" % (bid_results[0],bid_results[1],bid_results[2],bid_results[3],bid_results[4],bid_results[5],bid_values[0],bid_values[1],bid_values[2],bid_values[3],bid_values[4],bid_values[5], result2))
if output and not bid_output: if output and not bid_output:
print("\nStart ------- " + title) print("\nStart ------- " + title)
print ("".join([EnvCard2RealCard[c] for c in card_play_data["landlord"]])) if 'play' in card_play_data.keys():
print ("".join([EnvCard2RealCard[c] for c in card_play_data["landlord_down"]])) print ("".join([EnvCard2RealCard[c] for c in card_play_data['play']["landlord"]]))
print ("".join([EnvCard2RealCard[c] for c in card_play_data["landlord_front"]])) print ("".join([EnvCard2RealCard[c] for c in card_play_data['play']["landlord_down"]]))
print ("".join([EnvCard2RealCard[c] for c in card_play_data["landlord_up"]])) print ("".join([EnvCard2RealCard[c] for c in card_play_data['play']["landlord_front"]]))
print ("".join([EnvCard2RealCard[c] for c in card_play_data['play']["landlord_up"]]))
else:
print ("".join([EnvCard2RealCard[c] for c in card_play_data["landlord"]]))
print ("".join([EnvCard2RealCard[c] for c in card_play_data["landlord_down"]]))
print ("".join([EnvCard2RealCard[c] for c in card_play_data["landlord_front"]]))
print ("".join([EnvCard2RealCard[c] for c in card_play_data["landlord_up"]]))
# print(card_play_data) # print(card_play_data)
count = 0 count = 0
while not env.game_over and not bid_output: while not env.game_over and not bid_output:

View File

@ -15,9 +15,9 @@ deck.extend([20, 20, 30, 30])
def get_parser(): def get_parser():
parser = argparse.ArgumentParser(description='DouZero: random data generator') parser = argparse.ArgumentParser(description='DouZero: random data generator')
parser.add_argument('--output', default='eval_data', type=str) parser.add_argument('--output', default='eval_data_200', type=str)
parser.add_argument('--path', default='baselines/resnet_bidding_15419200.ckpt', type=str) parser.add_argument('--path', default='baselines/resnet_bidding_27853600.ckpt', type=str)
parser.add_argument('--num_games', default=10000, type=int) parser.add_argument('--num_games', default=200, type=int)
parser.add_argument('--exp_epsilon', default=0.01, type=float) parser.add_argument('--exp_epsilon', default=0.01, type=float)
return parser return parser