输出evaluation结果到csv

This commit is contained in:
zhiyang7 2021-12-24 18:17:51 +08:00
parent bea0624a1e
commit 24b88bae40
2 changed files with 20 additions and 3 deletions

View File

@ -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

View File

@ -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(