From 65d56eb007c0b34d4b698ee9aa2fa39dc86eb8f6 Mon Sep 17 00:00:00 2001 From: Lanly109 <1094916227@qq.com> Date: Mon, 4 Nov 2024 19:06:47 +0800 Subject: [PATCH 1/5] fix: travel receive request error --- autopcr/core/pcrclient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autopcr/core/pcrclient.py b/autopcr/core/pcrclient.py index 603b3d60..a8aec7be 100644 --- a/autopcr/core/pcrclient.py +++ b/autopcr/core/pcrclient.py @@ -92,7 +92,7 @@ async def travel_receive(self, travel_id: int, ex_auto_recycle_option: Union[Tra if ex_auto_recycle_option is None: ex_auto_recycle_option = TravelExtraEquipAutoRecycleOptionData(rarity=[], frame=[], category=[]) req = TravelReceiveRequest() - req.travel_quest_id = travel_id + req.travel_id = travel_id req.ex_auto_recycle_option = ex_auto_recycle_option return await self.request(req) From 80bbcae3a5e7a26042f44af9aafb3f92769b79c9 Mon Sep 17 00:00:00 2001 From: Lanly109 <1094916227@qq.com> Date: Mon, 4 Nov 2024 19:14:04 +0800 Subject: [PATCH 2/5] fix: check need power when travel start --- autopcr/module/modules/tools.py | 11 +++++++---- autopcr/util/ilp_solver.py | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/autopcr/module/modules/tools.py b/autopcr/module/modules/tools.py index d80322f1..eca5c5f2 100644 --- a/autopcr/module/modules/tools.py +++ b/autopcr/module/modules/tools.py @@ -55,6 +55,10 @@ async def do_task(self, client: pcrclient): teams_go = 3 - len(top.travel_quest_list) if not teams_go: raise AbortError("已经派遣了3支队伍") + if teams_go < len(travel_quest_id): + raise AbortError(f"可派队伍数量{teams_go}<需派图数{travel_quest_id}") + teams_go = len(travel_quest_id) + memory_unit = 3 * teams_go forbid_unit = [] @@ -89,9 +93,10 @@ async def do_task(self, client: pcrclient): candidate_unit_id = sorted([unit_id for unit_id in unit_power if unit_id not in unit_list and unit_id not in forbid_unit], key=lambda x: unit_power[x], reverse=True)[:teams_go * 7] candidate_unit_power = [unit_power[unit] for unit in candidate_unit_id] - ret, sol = dispatch_solver(start_power, candidate_unit_power, 7) + lb = [db.travel_quest_data[quest].need_power for quest in travel_quest_id] + ret, sol = dispatch_solver(start_power, candidate_unit_power, lb, 7) if not ret: - raise AbortError("无解!这不可能!") + raise AbortError(f"无法凑出战力满足最低要求的{teams_go}支队伍!") for pos, unit in zip(sol, candidate_unit_id): teams[pos].append(unit) @@ -104,8 +109,6 @@ async def do_task(self, client: pcrclient): if travel_team_go: self._log('----') - if len(travel_quest_id) != teams_go: - raise AbortError(f"队伍数量{teams_go}与派遣图数{travel_quest_id}不匹配") start_travel_quest_list: List[TravelStartInfo] = [] for id, (team, quest) in enumerate(zip(teams, travel_quest_id), start = 1): diff --git a/autopcr/util/ilp_solver.py b/autopcr/util/ilp_solver.py index 6b48d5c4..b5c416f5 100644 --- a/autopcr/util/ilp_solver.py +++ b/autopcr/util/ilp_solver.py @@ -29,11 +29,12 @@ def ilp_solver(ub: List[int], target: int, limit: int, effect: List[int]) -> Tup print(LpStatus[prob.status]) return prob.status == LpStatusOptimal, ret -def dispatch_solver(start: List[int], candidate: List[int], choose: int) -> Tuple[bool, List[int]]: +def dispatch_solver(start: List[int], candidate: List[int], lb: List[int], choose: int) -> Tuple[bool, List[int]]: ''' 数字分配,使得不同组的数字和尽可能平均 :param start: 组的初始数字和 :param candidate: 候选数字 + :param lb: 每组数字和的下界 :param choose: 每组选择的数字个数 :return: 是否有解,数字分配结果 ''' @@ -42,6 +43,7 @@ def vname(i, j): n = len(start) m = len(candidate) assert n * choose == m, "候选数需等于安排数" + assert len(start) == len(lb), "组数需等于组下界数" prob = LpProblem(name='dispatch', sense=LpMinimize) x = [[LpVariable(vname(j, i), lowBound=0, upBound=1, cat=LpInteger) for i in range(n)] for j in range(m)] @@ -56,6 +58,7 @@ def vname(i, j): for i in range(n): prob += lpSum([x[j][i] for j in range(m)]) == choose, f"dispatch_{i}" + prob += psum[i] >= lb[i], f"dispatch_lb_{i}" prob += max >= psum[i], f"max_{i}" prob += min <= psum[i], f"min_{i}" From ccba57c2de90f35bcdb6d28fa7e3d9467895287e Mon Sep 17 00:00:00 2001 From: Lanly109 <1094916227@qq.com> Date: Mon, 4 Nov 2024 19:14:56 +0800 Subject: [PATCH 3/5] fix: travel target day candidate & update default value --- autopcr/module/modules/sweep.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autopcr/module/modules/sweep.py b/autopcr/module/modules/sweep.py index e760f873..3dd859b5 100644 --- a/autopcr/module/modules/sweep.py +++ b/autopcr/module/modules/sweep.py @@ -23,7 +23,7 @@ '''.strip()) @singlechoice('travel_quest_gold_event_strategy', "代币事件策略", '赌狗', ['保守','赌狗','随机']) @singlechoice('travel_quest_equip_event_strategy', "装备事件策略", '赌狗', ['保守','赌狗','随机']) -@inttype('travel_quest_speed_up_paper_hold', "加速券保留", 6, list(range(3001))) +@inttype('travel_quest_speed_up_paper_hold', "加速券保留", 12, list(range(3001))) @name("探险续航") @default(True) class travel_quest_sweep(Module): @@ -470,8 +470,8 @@ class starcup1_sweep(starcup_sweep): def quest_id(self) -> int: return 19001001 -@inttype("travel_speed_up_paper_threshold", "加速阈值", 6, list(range(12))) -@inttype("travel_target_day", "轮转天数", 7, [2, 3, 5, 7, 10]) +@inttype("travel_speed_up_paper_threshold", "加速阈值", 12, list(range(13))) +@inttype("travel_target_day", "轮转天数", 7, list(range(1, 31))) @multichoice("travel_target_quest3", "轮转目标3", ['1-2','1-3','1-5'], db.travel_quest_candidate) @multichoice("travel_target_quest2", "轮转目标2", ['1-4'], db.travel_quest_candidate) @multichoice("travel_target_quest1", "轮转目标1", ['1-1'], db.travel_quest_candidate) From d58223a38f5510188bf3ed24e7792be08a6e0de6 Mon Sep 17 00:00:00 2001 From: lclbm <614867321@qq.com> Date: Wed, 6 Nov 2024 20:45:20 +0800 Subject: [PATCH 4/5] fea: speed up the specified travel maps --- autopcr/module/modules/sweep.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/autopcr/module/modules/sweep.py b/autopcr/module/modules/sweep.py index 3dd859b5..6cabe3e2 100644 --- a/autopcr/module/modules/sweep.py +++ b/autopcr/module/modules/sweep.py @@ -12,6 +12,7 @@ import random from collections import Counter import math +from typing import Set @description(''' @@ -21,6 +22,7 @@ 代币事件为 30%1000代币70%200代币 或 100%400代币 选项 赌狗策略为前者,保守策略为后者 '''.strip()) +@multichoice("travel_speed_up_target", "加速地图", ['1-1', '1-4'], db.travel_quest_candidate) @singlechoice('travel_quest_gold_event_strategy', "代币事件策略", '赌狗', ['保守','赌狗','随机']) @singlechoice('travel_quest_equip_event_strategy', "装备事件策略", '赌狗', ['保守','赌狗','随机']) @inttype('travel_quest_speed_up_paper_hold', "加速券保留", 12, list(range(3001))) @@ -146,8 +148,16 @@ def get_strategy(event_id: int) -> str: min(top.remain_daily_decrease_count_ticket, client.data.get_inventory(db.travel_speed_up_paper)) - travel_quest_speed_up_paper_hold, 0) if team_count and total_use: # avoid divide by zero + travel_speed_up_target = self.get_config("travel_speed_up_target") self._log(f"可使用加速券{total_use}张") - quest_use = [total_use // team_count + (i < total_use % team_count) for i in range(team_count)] + self._log(f"加速地图:{','.join(travel_speed_up_target)}") + speed_up_quest_id: Set[int] = {db.get_travel_quest_id_from_candidate(i) for i in travel_speed_up_target} + speed_up_team_count = sum(1 for quest in new_quest_list if quest.travel_quest_id in speed_up_quest_id) + quest_use = [total_use // speed_up_team_count if can_use else 0 for can_use in + [quest.travel_quest_id in speed_up_quest_id for quest in new_quest_list]] + if (paper_remain := total_use - sum(quest_use)) and speed_up_team_count: + for i in random.choices([i for i, v in enumerate(quest_use) if v], k=paper_remain): + quest_use[i] += 1 for quest, use in zip(new_quest_list, quest_use): if use: self._log(f"{db.get_quest_name(quest.travel_quest_id)}使用加速券x{use}") From cd11a39eab71b3be21a99411dfe743d86820d64b Mon Sep 17 00:00:00 2001 From: lclbm <614867321@qq.com> Date: Wed, 6 Nov 2024 22:39:29 +0800 Subject: [PATCH 5/5] fix: del log --- autopcr/module/modules/sweep.py | 1 - 1 file changed, 1 deletion(-) diff --git a/autopcr/module/modules/sweep.py b/autopcr/module/modules/sweep.py index 6cabe3e2..be391158 100644 --- a/autopcr/module/modules/sweep.py +++ b/autopcr/module/modules/sweep.py @@ -150,7 +150,6 @@ def get_strategy(event_id: int) -> str: if team_count and total_use: # avoid divide by zero travel_speed_up_target = self.get_config("travel_speed_up_target") self._log(f"可使用加速券{total_use}张") - self._log(f"加速地图:{','.join(travel_speed_up_target)}") speed_up_quest_id: Set[int] = {db.get_travel_quest_id_from_candidate(i) for i in travel_speed_up_target} speed_up_team_count = sum(1 for quest in new_quest_list if quest.travel_quest_id in speed_up_quest_id) quest_use = [total_use // speed_up_team_count if can_use else 0 for can_use in