From ade7128176462253c85bee281ce3be67cbdf0a45 Mon Sep 17 00:00:00 2001 From: MistEO Date: Thu, 11 Nov 2021 20:32:47 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix.=E4=BF=AE=E5=A4=8D=E6=B8=A9=E5=92=8C?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8D=E6=B8=85=E9=99=A4=E5=8E=9F=E6=9C=89?= =?UTF-8?q?=E5=B9=B2=E5=91=98=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAssistance/InfrastProductionTask.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/MeoAssistance/InfrastProductionTask.cpp b/src/MeoAssistance/InfrastProductionTask.cpp index 2220745f11..8c2036dac1 100644 --- a/src/MeoAssistance/InfrastProductionTask.cpp +++ b/src/MeoAssistance/InfrastProductionTask.cpp @@ -62,9 +62,14 @@ bool asst::InfrastProductionTask::shift_facility_list() continue; } auto& rect = add_analyzer.get_result().rect; - Rect add_button = add_task_ptr->rect_move; - add_button.x += rect.x; - add_button.y += rect.y; + Rect add_button = rect; + auto& rect_move = add_task_ptr->rect_move; + if (!rect_move.empty()) { + add_button.x += rect_move.x; + add_button.y += rect_move.y; + add_button.width = rect_move.width; + add_button.height = rect_move.height; + } /* 识别当前正在造什么 */ MatchImageAnalyzer product_analyzer(image); From 28104e254da4f81a2f850b5b5347ce8f24414890 Mon Sep 17 00:00:00 2001 From: MistEO Date: Thu, 11 Nov 2021 20:41:28 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix.=E4=BF=AE=E5=A4=8D=E4=B8=A4=E7=94=B5?= =?UTF-8?q?=E7=AB=99=E6=97=B6=E7=9A=84=E6=95=88=E7=8E=87=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAssistance/InfrastProductionTask.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/MeoAssistance/InfrastProductionTask.cpp b/src/MeoAssistance/InfrastProductionTask.cpp index 8c2036dac1..e734e20ea0 100644 --- a/src/MeoAssistance/InfrastProductionTask.cpp +++ b/src/MeoAssistance/InfrastProductionTask.cpp @@ -250,6 +250,7 @@ bool asst::InfrastProductionTask::optimal_calc() cur_opers.reserve(max_num_of_opers); double cur_efficient = 0; // 条件判断,不符合的直接过滤掉 + bool meet_condition = true; for (const auto& [cond, cond_value] : group.conditions) { if (!status.exist(cond)) { continue; @@ -257,9 +258,13 @@ bool asst::InfrastProductionTask::optimal_calc() // TODO:这里做成除了不等于,还可计算大于、小于等不同条件的 int cur_value = std::any_cast(status.get(cond)); if (cur_value != cond_value) { - continue; + meet_condition = false; + break; } } + if (!meet_condition) { + continue; + } // necessary里的技能,一个都不能少 for (const InfrastSkillsComb& nec_skills : group.necessary) { auto find_iter = std::find_if(cur_available_opers.cbegin(), cur_available_opers.cend(), From 79c9b5b5ca064253b17296318ee6a9b3cc3cba3f Mon Sep 17 00:00:00 2001 From: MistEO Date: Thu, 11 Nov 2021 21:42:04 +0800 Subject: [PATCH 3/5] =?UTF-8?q?fix.=E4=BF=AE=E5=A4=8D=E6=B8=85=E6=B5=81?= =?UTF-8?q?=E6=95=88=E7=8E=87=E8=AE=A1=E7=AE=97=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAssistance/InfrastProductionTask.cpp | 84 +++++++++++++-------- src/MeoAssistance/InfrastProductionTask.h | 1 + 2 files changed, 53 insertions(+), 32 deletions(-) diff --git a/src/MeoAssistance/InfrastProductionTask.cpp b/src/MeoAssistance/InfrastProductionTask.cpp index e734e20ea0..11c0d16541 100644 --- a/src/MeoAssistance/InfrastProductionTask.cpp +++ b/src/MeoAssistance/InfrastProductionTask.cpp @@ -163,37 +163,18 @@ size_t asst::InfrastProductionTask::opers_detect() max_num_of_opers_per_page = (std::max)(max_num_of_opers_per_page, cur_all_info.size()); for (const auto& cur_info : cur_all_info) { - auto find_iter = std::find_if(m_all_available_opers.cbegin(), m_all_available_opers.cend(), - [&cur_info](const InfrastOperSkillInfo& info) -> bool { - int dist = utils::hamming(cur_info.hash, info.hash); - return dist < HashDistThres; - }); + auto find_iter = std::find_if( + m_all_available_opers.cbegin(), m_all_available_opers.cend(), + [&cur_info](const InfrastOperSkillInfo& info) -> bool { + int dist = utils::hamming(cur_info.hash, info.hash); + return dist < HashDistThres; + }); // 如果两个的hash距离过小,则认为是同一个干员,不进行插入 if (find_iter != m_all_available_opers.cend()) { continue; } auto pred_info = cur_info; - // 根据正则,计算当前干员的实际效率 - for (auto&& [product, formula] : pred_info.skills_comb.efficient_regex) { - std::string cur_formula = formula; - for (size_t pos = 0; pos != std::string::npos;) { - pos = cur_formula.find('[', pos); - if (pos == std::string::npos) { - break; - } - size_t rp_pos = cur_formula.find(']', pos); - if (rp_pos == std::string::npos) { - break; - // TODO 报错! - } - std::string status_key = cur_formula.substr(pos + 1, rp_pos - pos - 1); - int status_value = std::any_cast(status.get(status_key)); - cur_formula.replace(pos, rp_pos - pos + 1, std::to_string(status_value)); - } - - int eff = calculator::eval(cur_formula); - pred_info.skills_comb.efficient[product] = eff; - } + pred_info.skills_comb = efficient_regex_calc(pred_info.skills_comb); m_all_available_opers.emplace_back(std::move(pred_info)); } return cur_all_info.size(); @@ -267,16 +248,23 @@ bool asst::InfrastProductionTask::optimal_calc() } // necessary里的技能,一个都不能少 for (const InfrastSkillsComb& nec_skills : group.necessary) { - auto find_iter = std::find_if(cur_available_opers.cbegin(), cur_available_opers.cend(), - [&](const InfrastOperSkillInfo& arg) -> bool { - return arg.skills_comb == nec_skills; - }); + auto find_iter = std::find_if( + cur_available_opers.cbegin(), cur_available_opers.cend(), + [&](const InfrastOperSkillInfo& arg) -> bool { + return arg.skills_comb == nec_skills; + }); if (find_iter == cur_available_opers.cend()) { group_unavailable = true; break; } cur_opers.emplace_back(nec_skills); - cur_efficient += nec_skills.efficient.at(m_product); + if (auto iter = nec_skills.efficient_regex.find(m_product); + iter != nec_skills.efficient_regex.cend()) { + cur_efficient += efficient_regex_calc(nec_skills).efficient.at(m_product); + } + else { + cur_efficient += nec_skills.efficient.at(m_product); + } cur_available_opers.erase(find_iter); } if (group_unavailable) { @@ -299,7 +287,13 @@ bool asst::InfrastProductionTask::optimal_calc() }); if (find_iter != cur_available_opers.cend()) { cur_opers.emplace_back(opt); - cur_efficient += opt.efficient.at(m_product); + if (auto iter = opt.efficient_regex.find(m_product); + iter != opt.efficient_regex.cend()) { + cur_efficient += efficient_regex_calc(opt).efficient.at(m_product); + } + else { + cur_efficient += opt.efficient.at(m_product); + } find_iter = cur_available_opers.erase(find_iter); } else { @@ -422,6 +416,32 @@ bool asst::InfrastProductionTask::opers_choose() return true; } +asst::InfrastSkillsComb asst::InfrastProductionTask::efficient_regex_calc(InfrastSkillsComb skills_comb) const +{ + // 根据正则,计算当前干员的实际效率 + for (auto&& [product, formula] : skills_comb.efficient_regex) { + std::string cur_formula = formula; + for (size_t pos = 0; pos != std::string::npos;) { + pos = cur_formula.find('[', pos); + if (pos == std::string::npos) { + break; + } + size_t rp_pos = cur_formula.find(']', pos); + if (rp_pos == std::string::npos) { + break; + // TODO 报错! + } + std::string status_key = cur_formula.substr(pos + 1, rp_pos - pos - 1); + int status_value = std::any_cast(status.get(status_key)); + cur_formula.replace(pos, rp_pos - pos + 1, std::to_string(status_value)); + } + + int eff = calculator::eval(cur_formula); + skills_comb.efficient[product] = eff; + } + return skills_comb; +} + bool asst::InfrastProductionTask::facility_list_detect() { LogTraceFunction; diff --git a/src/MeoAssistance/InfrastProductionTask.h b/src/MeoAssistance/InfrastProductionTask.h index 7e558bd503..cfa6d1c8bb 100644 --- a/src/MeoAssistance/InfrastProductionTask.h +++ b/src/MeoAssistance/InfrastProductionTask.h @@ -29,6 +29,7 @@ namespace asst size_t opers_detect(); // 返回当前页面的干员数 bool optimal_calc(); bool opers_choose(); + InfrastSkillsComb efficient_regex_calc(InfrastSkillsComb skill_info) const; constexpr static int HashDistThres = 25; From b9b35bb55b6f2a0eb24a54a1c605184c681cf74f Mon Sep 17 00:00:00 2001 From: MistEO Date: Thu, 11 Nov 2021 21:58:36 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix.=E4=BF=AE=E5=A4=8D=E8=B4=B8=E6=98=93?= =?UTF-8?q?=E7=AB=99=E6=97=A0=E4=BA=BA=E6=9C=BA=E7=94=A8=E4=B8=8D=E5=AE=8C?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resource/tasks.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/resource/tasks.json b/resource/tasks.json index 7644968428..6219422c08 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -1,4 +1,4 @@ -{ +{ "SanityBegin": { "algorithm": "justreturn", "action": "doNothing", @@ -800,7 +800,7 @@ }, "DroneConfirm": { "action": "clickSelf", - "rearDelay": 3000, + "rearDelay": 2000, "templThreshold": 0.8, "next": [ "DeliverableOrder", @@ -814,7 +814,8 @@ "next": [ "DeliverableOrder", "DroneAssist-Trade" - ] + ], + "rearDelay": 2000 }, "DroneAssist-Trade-Stop": { "Doc": "如果找到了“无人机加速”按钮,却没有找到订单交付:说明上一次无人机没有把一个订单加速完成,也说明没有更多的无人机了,所以直接stop", From 30bb18dc7b08973b33c245c99b4ad102aadad019 Mon Sep 17 00:00:00 2001 From: MistEO Date: Thu, 11 Nov 2021 22:05:29 +0800 Subject: [PATCH 5/5] =?UTF-8?q?chore.=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAssistance/Version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MeoAssistance/Version.h b/src/MeoAssistance/Version.h index 0e0cdf764e..616e25dc62 100644 --- a/src/MeoAssistance/Version.h +++ b/src/MeoAssistance/Version.h @@ -1,6 +1,6 @@ -#pragma once +#pragma once namespace asst { - constexpr static const char* Version = "v1.3.0"; + constexpr static const char* Version = "v1.3.1"; }