From 3300fd96588960fa23165b16a9f9f509b389653b Mon Sep 17 00:00:00 2001 From: zhiyang7 Date: Fri, 10 Dec 2021 10:11:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=AB=E7=89=8C=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E7=9A=84=E8=AF=84=E4=BC=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- douzero/env/game.py | 29 ++++++++++++++++++++--------- douzero/evaluation/simulation.py | 14 ++++++++++---- generate_eval_data_with_bid.py | 6 +++--- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/douzero/env/game.py b/douzero/env/game.py index 4afdc3f..c898a27 100644 --- a/douzero/env/game.py +++ b/douzero/env/game.py @@ -86,15 +86,26 @@ class GameEnv(object): def card_play_init(self, card_play_data): - 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'] + if 'bid' in card_play_data.keys(): + self.info_sets['landlord'].bid_info = card_play_data['bid']['landlord'] + self.info_sets['landlord_up'].bid_info = card_play_data['bid']['landlord_up'] + self.info_sets['landlord_front'].bid_info = card_play_data['bid']['landlord_front'] + self.info_sets['landlord_down'].bid_info = card_play_data['bid']['landlord_down'] + + self.info_sets['landlord'].player_hand_cards = card_play_data['play']['landlord'] + self.info_sets['landlord_up'].player_hand_cards = card_play_data['play']['landlord_up'] + 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.game_infoset = self.get_infoset() diff --git a/douzero/evaluation/simulation.py b/douzero/evaluation/simulation.py index 2e66a97..e5b38cb 100644 --- a/douzero/evaluation/simulation.py +++ b/douzero/evaluation/simulation.py @@ -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)) if output and not bid_output: print("\nStart ------- " + title) - 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"]])) + if 'play' in card_play_data.keys(): + print ("".join([EnvCard2RealCard[c] for c in card_play_data['play']["landlord"]])) + print ("".join([EnvCard2RealCard[c] for c in card_play_data['play']["landlord_down"]])) + 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) count = 0 while not env.game_over and not bid_output: diff --git a/generate_eval_data_with_bid.py b/generate_eval_data_with_bid.py index 1803109..1855dc8 100644 --- a/generate_eval_data_with_bid.py +++ b/generate_eval_data_with_bid.py @@ -15,9 +15,9 @@ deck.extend([20, 20, 30, 30]) def get_parser(): parser = argparse.ArgumentParser(description='DouZero: random data generator') - parser.add_argument('--output', default='eval_data', type=str) - parser.add_argument('--path', default='baselines/resnet_bidding_15419200.ckpt', type=str) - parser.add_argument('--num_games', default=10000, type=int) + parser.add_argument('--output', default='eval_data_200', type=str) + parser.add_argument('--path', default='baselines/resnet_bidding_27853600.ckpt', type=str) + parser.add_argument('--num_games', default=200, type=int) parser.add_argument('--exp_epsilon', default=0.01, type=float) return parser