88 lines
2.5 KiB
Python
88 lines
2.5 KiB
Python
"""
|
||
直接测试阵容推荐功能,不通过HTTP请求
|
||
"""
|
||
from src.data_provider import DataQueryAPI
|
||
from src.scoring.scoring_system import TeamScorer
|
||
from src.recommendation import RecommendationEngine
|
||
import copy
|
||
|
||
def test_direct_recommendation():
|
||
"""直接测试阵容推荐功能"""
|
||
# 创建自定义配置
|
||
config = {
|
||
"base_weights": {
|
||
"synergy_level_weight": 1.5,
|
||
"synergy_count_weight": 0.8,
|
||
"chess_cost_weight": 0.3
|
||
},
|
||
"synergy_weights": {
|
||
"重装战士": 2.0,
|
||
"斗士": 1.8
|
||
},
|
||
"chess_weights": {
|
||
"盖伦": 2.0,
|
||
"赛娜": 2.5
|
||
},
|
||
"synergy_level_weights": {
|
||
"1": 1.0,
|
||
"2": 1.2,
|
||
"3": 1.5,
|
||
"4": 1.8,
|
||
"5": 2.0,
|
||
"6": 2.3,
|
||
"7": 2.6,
|
||
"8": 3.0,
|
||
"9": 3.3,
|
||
"10": 3.5
|
||
},
|
||
"cost_weights": {
|
||
"1": 1.0,
|
||
"2": 1.2,
|
||
"3": 1.5,
|
||
"4": 1.8,
|
||
"5": 2.0
|
||
}
|
||
}
|
||
|
||
# 初始化组件
|
||
data_api = DataQueryAPI()
|
||
scorer = TeamScorer(api=data_api, config_obj=copy.deepcopy(config))
|
||
engine = RecommendationEngine(api=data_api, scorer=scorer, config_obj=copy.deepcopy(config))
|
||
|
||
# 定义参数
|
||
population = 9
|
||
required_synergies = [] # 这里可以添加必选羁绊
|
||
required_chess = [] # 这里可以添加必选棋子
|
||
max_results = 3
|
||
|
||
# 生成阵容推荐
|
||
print("正在生成阵容推荐...")
|
||
teams = engine.recommend_team(
|
||
population=population,
|
||
required_synergies=required_synergies,
|
||
required_chess=required_chess,
|
||
max_results=max_results
|
||
)
|
||
|
||
# 打印结果
|
||
print(f"生成了 {len(teams)} 个推荐阵容")
|
||
|
||
for i, team in enumerate(teams):
|
||
print(f"\n阵容 #{i+1} (评分: {team.score:.2f})")
|
||
|
||
print("\n棋子列表:")
|
||
for chess in team.chess_list:
|
||
print(f" {chess.get('displayName')} ({chess.get('price')}费)")
|
||
|
||
print("\n激活的职业羁绊:")
|
||
for job in team.synergy_levels['job']:
|
||
print(f" {job['name']} (等级 {job['level']})")
|
||
|
||
print("\n激活的特质羁绊:")
|
||
for race in team.synergy_levels['race']:
|
||
print(f" {race['name']} (等级 {race['level']})")
|
||
|
||
print("\n" + "-"*50)
|
||
|
||
if __name__ == "__main__":
|
||
test_direct_recommendation() |