From 24b88bae40504c188ba394ade38816f4b3dd30cd Mon Sep 17 00:00:00 2001 From: zhiyang7 Date: Fri, 24 Dec 2021 18:17:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BE=93=E5=87=BAevaluation=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E5=88=B0csv?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- douzero/evaluation/simulation.py | 9 +++++++-- evaluate.py | 14 +++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/douzero/evaluation/simulation.py b/douzero/evaluation/simulation.py index 1b8cec0..e2a5c71 100644 --- a/douzero/evaluation/simulation.py +++ b/douzero/evaluation/simulation.py @@ -123,6 +123,11 @@ def evaluate(landlord, landlord_up, landlord_front, landlord_down, eval_data, nu num_total_wins = num_landlord_wins + num_farmer_wins print('WP results:') - print('landlord : Farmers - {} : {}'.format(num_landlord_wins / num_total_wins, num_farmer_wins / num_total_wins)) + landlord_wp = num_landlord_wins / num_total_wins + farmer_wp = num_farmer_wins / num_total_wins + print('landlord : Farmers - {} : {}'.format(landlord_wp, farmer_wp)) print('ADP results:') - print('landlord : Farmers - {} : {}'.format(num_landlord_scores / num_total_wins, 3 * num_farmer_scores / num_total_wins)) + landlord_adp = num_landlord_scores / num_total_wins + farmer_adp = 3 * num_farmer_scores / num_total_wins + print('landlord : Farmers - {} : {}'.format(landlord_adp, farmer_adp)) + return landlord_wp, farmer_wp, landlord_adp, farmer_adp diff --git a/evaluate.py b/evaluate.py index 959df46..2306b5f 100644 --- a/evaluate.py +++ b/evaluate.py @@ -1,6 +1,7 @@ import os import argparse from pickle import FALSE +import csv from douzero.evaluation.simulation import evaluate @@ -32,7 +33,8 @@ def make_evaluate(args, vs_config): print('%s %i\tvs\t%s %i' % ( landlord_config['prefix'], landlord_config['frame'], farmer_config['prefix'], farmer_config['frame'])) - evaluate(args.landlord, + + landlord_wp, farmer_wp, landlord_adp, farmer_adp = evaluate(args.landlord, args.landlord_up, args.landlord_front, args.landlord_down, @@ -41,6 +43,16 @@ def make_evaluate(args, vs_config): args.output, args.title) + with open('result.csv', 'w') as csvfile: + writer = csv.writer(csvfile) + writer.writerow([ + landlord_wp, + farmer_wp, + landlord_adp, + farmer_adp + ]) + + if __name__ == '__main__': parser = argparse.ArgumentParser(