From c5fbd4bb9303f0db71d799e1609e295ddbbc7baa Mon Sep 17 00:00:00 2001 From: MistEO Date: Fri, 21 Jan 2022 22:54:59 +0800 Subject: [PATCH] =?UTF-8?q?opt.=E4=BC=98=E5=8C=96=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=88=98=E6=96=97=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAssistant/BattlePerspectiveImageAnalyzer.cpp | 8 ++++---- src/MeoAssistant/BattleTask.cpp | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/MeoAssistant/BattlePerspectiveImageAnalyzer.cpp b/src/MeoAssistant/BattlePerspectiveImageAnalyzer.cpp index 79bdca48da..9c1238923d 100644 --- a/src/MeoAssistant/BattlePerspectiveImageAnalyzer.cpp +++ b/src/MeoAssistant/BattlePerspectiveImageAnalyzer.cpp @@ -55,8 +55,8 @@ bool asst::BattlePerspectiveImageAnalyzer::placed_analyze() int h = stats.at(i, cv::CC_STAT_HEIGHT); m_available_placed.emplace_back(Rect(x, y, w, h)); - int center_x = centroids.at(i, 0); - int center_y = centroids.at(i, 1); + int center_x = static_cast(centroids.at(i, 0)); + int center_y = static_cast(centroids.at(i, 1)); placed_centers.emplace_back(Point(center_x, center_y)); #ifdef ASST_DEBUG @@ -76,8 +76,8 @@ bool asst::BattlePerspectiveImageAnalyzer::placed_analyze() auto nearest_iter = std::min_element(placed_centers.cbegin(), placed_centers.cend(), [&home](const Point& lhs, const Point& rhs) -> bool { - int lhs_dist = std::pow((home.x - lhs.x), 2) + std::pow((home.y - lhs.y), 2); - int rhs_dist = std::pow((home.x - rhs.x), 2) + std::pow((home.y - rhs.y), 2); + double lhs_dist = std::pow((home.x - lhs.x), 2) + std::pow((home.y - lhs.y), 2); + double rhs_dist = std::pow((home.x - rhs.x), 2) + std::pow((home.y - rhs.y), 2); return lhs_dist < rhs_dist; }); if (nearest_iter == placed_centers.cend()) { diff --git a/src/MeoAssistant/BattleTask.cpp b/src/MeoAssistant/BattleTask.cpp index 720dcd39f5..9d5e8d26d5 100644 --- a/src/MeoAssistant/BattleTask.cpp +++ b/src/MeoAssistant/BattleTask.cpp @@ -33,11 +33,11 @@ bool asst::BattleTask::auto_battle() } static const std::array RoleOrder = { - Role::Medic, Role::Pioneer, Role::Sniper, Role::Warrior, Role::Support, + Role::Medic, Role::Caster, Role::Special, Role::Tank, @@ -84,13 +84,18 @@ bool asst::BattleTask::auto_battle() int dx = nearest_point.x - home_center.x; int dy = nearest_point.y - home_center.y; + if ((dx * 7) < (dy * 11)) { + dx = 0; + } + else { + dy = 0; + } + constexpr int coeff = 5; Point end_point; - switch (opt_oper.role) { case Role::Medic: case Role::Support: { - constexpr int coeff = 5; end_point.x = nearest_point.x - coeff * dx; end_point.y = nearest_point.y - coeff * dy; } @@ -104,7 +109,6 @@ bool asst::BattleTask::auto_battle() case Role::Drone: default: { - constexpr int coeff = 5; end_point.x = nearest_point.x + coeff * dx; end_point.y = nearest_point.y + coeff * dy; }