perf: 优化葛朗台,碎石在理智不会溢出时不再等待

close #11048
This commit is contained in:
status102
2024-11-26 09:51:04 +08:00
parent 3255350583
commit c45e9703d2
4 changed files with 23 additions and 5 deletions

View File

@@ -5267,7 +5267,8 @@
["만", "万"],
["億", "亿"],
["억", "亿"],
["^\\.", ""]
["^\\.", ""],
[" ", ""]
]
},
"StageDrops-Difficulty-Tough": {

View File

@@ -2,6 +2,7 @@
#include "Config/TaskData.h"
#include "Controller/Controller.h"
#include "Task/Fight/MedicineCounterTaskPlugin.h"
#include "Utils/Logger.hpp"
#include "Vision/OCRer.h"
@@ -26,7 +27,19 @@ bool asst::DrGrandetTaskPlugin::_run()
{
LogTraceFunction;
int cur_ms = analyze_time_left(ctrler()->get_image());
const auto& image = ctrler()->get_image();
auto sanity_target = MedicineCounterTaskPlugin::get_target_of_sanity(image);
auto sanity_max = MedicineCounterTaskPlugin::get_maximun_of_sanity(image);
if (!sanity_target || !sanity_max) [[unlikely]] {
return false;
}
if (*sanity_target < *sanity_max) {
return true;
}
int cur_ms = analyze_time_left(image);
if (cur_ms < 0) {
return false;
}

View File

@@ -20,6 +20,9 @@ public:
int get_used_count() const { return m_used_count; }
static std::optional<int> get_target_of_sanity(const cv::Mat& image);
static std::optional<int> get_maximun_of_sanity(const cv::Mat& image);
private:
virtual bool _run() override;
@@ -49,8 +52,6 @@ private:
std::optional<MedicineResult> init_count(cv::Mat image) const;
// 减少药品使用
void reduce_excess(const MedicineResult& using_medicine);
std::optional<int> get_target_of_sanity(const cv::Mat& image);
std::optional<int> get_maximun_of_sanity(const cv::Mat& image);
bool m_use_expiring = false;
bool m_dr_grandet = false;

View File

@@ -12,6 +12,7 @@
#include "Vision/Matcher.h"
#include "Vision/Miscellaneous/DepotImageAnalyzer.h"
#include "Vision/Miscellaneous/StageDropsImageAnalyzer.h"
#include "Task/Fight/MedicineCounterTaskPlugin.h"
asst::DebugTask::DebugTask(const AsstCallback& callback, Assistant* inst) :
InterfaceTask(callback, inst, TaskType)
@@ -20,7 +21,9 @@ asst::DebugTask::DebugTask(const AsstCallback& callback, Assistant* inst) :
bool asst::DebugTask::run()
{
test_match_template();
auto img = imread(utils::path("C:\\Users\\status102\\Documents\\MuMu共享文件夹\\Screenshots/MuMu12-20241126-0940511.png"));
auto max = MedicineCounterTaskPlugin::get_maximun_of_sanity(img);
auto tgt = MedicineCounterTaskPlugin::get_target_of_sanity(img);
return true;
}