调整样式,抽取参数
This commit is contained in:
parent
4f86e26118
commit
0c3abc98c1
|
@ -10,17 +10,20 @@ positions = ['landlord', 'landlord_up', 'landlord_front', 'landlord_down']
|
|||
idx_position = {0: 'landlord', 1: 'landlord_down', 2: 'landlord_front', 3:'landlord_up'}
|
||||
position_idx = {'landlord': 0, 'landlord_down': 1, 'landlord_front': 2, 'landlord_up': 3}
|
||||
|
||||
baselines = Baseline.select().order_by(Baseline.rank.desc()).limit(1)
|
||||
baseline_players = [None, None, None, None]
|
||||
if len(baselines) >= 1:
|
||||
baseline = baselines[0]
|
||||
try:
|
||||
baseline_players[0] = DeepAgent('landlord', str(baseline.landlord_path), use_onnx=True)
|
||||
baseline_players[1] = DeepAgent('landlord_down', str(baseline.landlord_down_path), use_onnx=True)
|
||||
baseline_players[2] = DeepAgent('landlord_front', str(baseline.landlord_front_path), use_onnx=True)
|
||||
baseline_players[3] = DeepAgent('landlord_up', str(baseline.landlord_up_path), use_onnx=True)
|
||||
except:
|
||||
pass
|
||||
|
||||
def init_battlefield(flags):
|
||||
global baseline_players
|
||||
baselines = Baseline.select().order_by(Baseline.rank.desc()).limit(1)
|
||||
if len(baselines) >= 1:
|
||||
baseline = baselines[0]
|
||||
try:
|
||||
baseline_players[0] = DeepAgent('landlord', str(baseline.landlord_path), use_onnx=True)
|
||||
baseline_players[1] = DeepAgent('landlord_down', str(baseline.landlord_down_path), use_onnx=True)
|
||||
baseline_players[2] = DeepAgent('landlord_front', str(baseline.landlord_front_path), use_onnx=True)
|
||||
baseline_players[3] = DeepAgent('landlord_up', str(baseline.landlord_up_path), use_onnx=True)
|
||||
except:
|
||||
pass
|
||||
|
||||
def battle_logic(baseline : Baseline, battle : Battle):
|
||||
eval_data_first = 'eval_data_200.pkl'
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
# -*- coding:utf8 -*-
|
||||
from peewee import *
|
||||
|
||||
db = MySQLDatabase('dou_model', host='192.168.1.88', user='douzero', passwd='VwjT6e0qf2t9iOH0')
|
||||
db = MySQLDatabase(None)
|
||||
|
||||
def init_db(flags):
|
||||
db.init(flags.db_schema, host=flags.db_host, user=flags.db_user, passwd=flags.db_passwd)
|
||||
Model.create_table()
|
||||
Battle.create_table()
|
||||
Baseline.create_table()
|
||||
|
||||
|
||||
class BaseModel(Model):
|
||||
class Meta:
|
||||
|
|
|
@ -5,8 +5,8 @@ import threading
|
|||
|
||||
from peewee import JOIN
|
||||
|
||||
from douzero.server.orm import Model, Battle, Baseline
|
||||
from douzero.server.battle import tick, baseline_players, positions, idx_position
|
||||
from douzero.server.orm import init_db, Model, Battle, Baseline
|
||||
from douzero.server.battle import init_battlefield, tick, baseline_players, positions, idx_position
|
||||
from flask import Flask, jsonify, request
|
||||
from flask_cors import CORS
|
||||
from datetime import datetime
|
||||
|
@ -16,10 +16,6 @@ from douzero.env.game import get_legal_card_play_actions
|
|||
app = Flask(__name__)
|
||||
CORS(app)
|
||||
|
||||
Model.create_table()
|
||||
Battle.create_table()
|
||||
Baseline.create_table()
|
||||
|
||||
EnvCard2RealCard = {3: '3', 4: '4', 5: '5', 6: '6', 7: '7',
|
||||
8: '8', 9: '9', 10: 'T', 11: 'J', 12: 'Q',
|
||||
13: 'K', 14: 'A', 17: '2', 20: 'X', 30: 'D'}
|
||||
|
@ -278,6 +274,14 @@ if __name__ == '__main__':
|
|||
import argparse
|
||||
parser = argparse.ArgumentParser(description='DouZero evaluation backend')
|
||||
parser.add_argument('--debug', action='store_true')
|
||||
parser.add_argument('--enable_task', type=bool)
|
||||
parser.add_argument('--db_host', type=str, default='127.0.0.1')
|
||||
parser.add_argument('--db_schema', type=str, default='dou_model')
|
||||
parser.add_argument('--db_user', type=str, default='douzero')
|
||||
parser.add_argument('--db_passwd', type=str, default='VwjT6e0qf2t9iOH0')
|
||||
args = parser.parse_args()
|
||||
start_runner()
|
||||
init_db(args)
|
||||
init_battlefield(args)
|
||||
if args.enable_task:
|
||||
start_runner()
|
||||
app.run(debug=args.debug, host="0.0.0.0")
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
<head>
|
||||
<script src="https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js"></script>
|
||||
<script src="https://code.highcharts.com/highcharts.js"></script>
|
||||
<script src="https://code.highcharts.com/modules/series-label.js"></script>
|
||||
<script src="https://code.highcharts.com/modules/exporting.js"></script>
|
||||
<script src="https://code.highcharts.com/modules/export-data.js"></script>
|
||||
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<select id='model_type'>
|
||||
|
@ -27,7 +31,6 @@
|
|||
var i = 0
|
||||
positions = ['landlord', 'landlord_down', 'landlord_front', 'landlord_up']
|
||||
for (var rank in result) {
|
||||
debugger
|
||||
if (!result.hasOwnProperty(rank)) {
|
||||
continue
|
||||
}
|
||||
|
@ -43,6 +46,52 @@
|
|||
result[rank]['baseline'].landlord_front_path + '\t/\t' +
|
||||
result[rank]['baseline'].landlord_up_path
|
||||
},
|
||||
colors: ['#e02f1b', '#a82314', '#1be02f', '#14a823', '#1bcce0', '#1499a8', '#2f1be0', '#2314a8'],
|
||||
yAxis: [
|
||||
{
|
||||
title: {text: 'Win Rate (%)'},
|
||||
plotLines: [
|
||||
{
|
||||
label: { text: 'landlord_wp'},
|
||||
color: '#e0887e',
|
||||
width: 2,
|
||||
zIndex: 5,
|
||||
value: parseFloat(result[rank]['baseline'].landlord_wp) * 100,
|
||||
dashStyle: 'shortdash'
|
||||
},
|
||||
{
|
||||
label: { text: 'farmer_wp'},
|
||||
color: '#7ed6e0',
|
||||
width: 2,
|
||||
zIndex: 5,
|
||||
value: parseFloat(result[rank]['baseline'].farmer_wp) * 100,
|
||||
dashStyle: 'shortdash'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: { text: 'ADP'},
|
||||
opposite: true,
|
||||
plotLines: [
|
||||
{
|
||||
label: { text: 'landlord_adp'},
|
||||
color: '#e0887e',
|
||||
width: 2,
|
||||
value: parseFloat(result[rank]['baseline'].landlord_adp),
|
||||
zIndex: 5,
|
||||
dashStyle: 'longdashdot'
|
||||
},
|
||||
{
|
||||
label: { text: 'farmer_adp'},
|
||||
color: '#7ed6e0',
|
||||
width: 2,
|
||||
value: parseFloat(result[rank]['baseline'].farmer_adp),
|
||||
zIndex: 5,
|
||||
dashStyle: 'longdashdot'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
categories = new Set()
|
||||
$.map(positions, function (position) {
|
||||
|
@ -51,6 +100,9 @@
|
|||
})
|
||||
})
|
||||
categories = Array.from(categories).sort()
|
||||
json.xAxis = {
|
||||
categories: categories
|
||||
}
|
||||
json.series = $.map(positions, function (position) {
|
||||
if (!result[rank].hasOwnProperty(position)) {
|
||||
return null;
|
||||
|
@ -88,19 +140,6 @@
|
|||
})
|
||||
}]
|
||||
})
|
||||
json.xAxis = {
|
||||
categories: categories
|
||||
}
|
||||
json.yAxis = [{
|
||||
title: {
|
||||
text: 'Win Rate (%)'
|
||||
}
|
||||
}, {
|
||||
title: {
|
||||
text: 'ADP'
|
||||
},
|
||||
opposite: true
|
||||
}];
|
||||
json.legend = {
|
||||
layout: 'vertical',
|
||||
align: 'right',
|
||||
|
@ -108,6 +147,8 @@
|
|||
borderWidth: 0
|
||||
};
|
||||
$('#container_' + i).highcharts(json);
|
||||
debugger
|
||||
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue